Mein MATLAB Forum - goMatlab.de

Mein MATLAB Forum

 
Gast > Registrieren       Autologin?   
Bücher:

Fachkräfte:
Entwicklungsingenieur (m/w) für modellbasierte Softwareentwicklung
Modellbasierte Softwareentwicklung mit MATLAB/Simulink und dSPACE TargetLink
Elektronische Fahrwerksysteme GmbH - Ingolstadt

Softwareentwickler (m/w) für automatische Codegenerierung
Softwareentwicklung mit MATLAB/Simulink und dSPACE TargetLink im Bereich Fahrwerkregelsysteme
Elektronische Fahrwerksysteme GmbH - Ingolstadt

Elektromobilität: E-Drive Entwicklungsingenieur HV-Energiemanagement und Betriebsstrategie (m/w)
Entwicklung von Teilfunktionen für Energiebordnetze
MBtech Group GmbH & Co. KGaA - Sindelfingen

Entwicklungsingenieur (m/w) für Fahrdynamikregelsysteme
Entwicklung der für die Fahrdynamik relevanten Funktionen
Elektronische Fahrwerksysteme GmbH - Ingolstadt

Softwareentwickler (w/m) Bypassing- und Steuergeräte-Schnittstellen
Entwicklung von Echtzeit-Software für verschiedene automotive Microcontroller
dSPACE GmbH - Paderborn

weitere Angebote

Partner:


Vermarktungspartner


Forum
      Option
[Erweitert]
  • Diese Seite per Mail weiterempfehlen
     


Gehe zu:  
Neues Thema eröffnen Neue Antwort erstellen

Leistungsdichtespektrum aus Messwerten erstellen

 

Ollisch90
Forum-Newbie

Forum-Newbie


Beiträge: 1
Anmeldedatum: 11.06.17
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 11.06.2017, 22:33     Titel: Leistungsdichtespektrum aus Messwerten erstellen
  Antworten mit Zitat      
Hallo Leute!

Dies ist mein erster Eintrag in diesem Forum und ich hoffe ihr könnt mir weiterhelfen.
Ich habe natürlich schon die Suche benutzt und auch einige Stunden auf Google zugebracht.

Ich habe Beschleunigungsmesswerte, welche mit einer App aufgenommen wurden. Diese sind in einer Exceldatei gespeichert mit den Spalten "Zeit" "Beschleunigung X" "Beschleunigung Y" "Beschleunigung Z".
Das Ziel wäre es, mit diesen Messwerten eine windowed FFT zu machen und dann ein Leistungsdichtespektrum zu ermitteln, um später Energie aus den Vibrationen zu abzugreifen.

Da ich noch ein Scilab-Neuling bin wollte ich fragen ob jemand das schon einmal gemacht hat oder mir grundlegend erklären kann, wie ich das angehe.

Zunächst dachte ich daran die Datei im CSV-Format abzuspeichern und dann über den read_input_file-Block in xcos einzulesen. Doch so wie ich es hier in einigen Beiträgen gesehen habe, wäre es wohl besser die Datei über den Konsolenbefehl xls_read einzulesen?

Vielen Dank schon mal und liebe Grüße! Wink
Private Nachricht senden Benutzer-Profile anzeigen


brummfritz
Forum-Anfänger

Forum-Anfänger


Beiträge: 20
Anmeldedatum: 01.09.16
Wohnort: Düsseldorf
Version: Matlab R2015b
     Beitrag Verfasst am: 15.06.2017, 23:59     Titel:
  Antworten mit Zitat      

Leistungsdichtespektrum aus Messwerten erstellen
Klicke hier, um den Artikel bei Amazon.de anzuschauen.

Hallo ollisch90

auf meiner Internetseite derbrummton.de habe ich kleine Scripts mit Scilab eingestellt.
Vielleicht hilft das?
gruß

Scilab ist ein tolles Programm!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


S C I L A B

z.B.
Code:
//
mclose('all');
clear
zi=struct('pfad','','dateiname','','fe','','sr',0,'start1',0,'start2',0,'info',0,'lz',0,'so',0,'yF',0,'afft',0,'afftl',0,'g',0,'f',0,'l',0,'r',0,'h1',0,'h2',0,'h3',0,'h4',0,'v',1);
/////////////////////////////
// formular
zi.f=gcf();//
zi.f.color_map = jetcolormap(1000); //Colormap festlegen
zi.f.visible = "on";
zi.f.figure_position = [20,20];
zi.f.figure_size = [1400,900];
zi.f.figure_name="Wav - Zeit- Frequenz - FFT - Analyse";
zi.f.BackgroundColor=[1 1 1];
zi.tag='Formular';
zi.so=0;
// controls
u1=uicontrol(zi.f,"style","pushbutton", 'position', [500 40 60 30],'string','Neu','callback','[zi]=neu(zi)');
u2=uicontrol(zi.f,"style","pushbutton", 'position', [570 40 50 30],'string','<<','callback','[zi]=links(zi)');
u3=uicontrol(zi.f,"style","text",'HorizontalAlignment','center' ,'position', [635 40 90 30],'string','0. Sek.');
u4=uicontrol(zi.f,"style","pushbutton", 'position', [740 40 50 30],'string','>>','callback','[zi]=rechts(zi)');
u5=uicontrol(zi.f,"style","pushbutton", 'position', [800 40 60 30],'string','Exit','callback','close');
u6=uicontrol(zi.f,"style","text",'HorizontalAlignment','left' ,'position', [100 5 1200 30],'string',zi.fe);
u7=uicontrol(zi.f,"style","spinner", 'position', [660 100 50 40],'HorizontalAlignment','center','VerticalAlignment','middle','min',1,'max',10,'SliderStep',[1,10],'SliderStep',[1,10],'Title_position','top','callback','[zi]=verst(zi)');
u8=uicontrol(zi.f,"style","text",'HorizontalAlignment','left' ,'position', [658 145 60 20],'string','Verstärkung');

//
/////////////////////////////////
//
//
// functionen
function [zi]=neu(zi)
//////////////////////////////////////////////////////////////////////////////
if zi.so>0 then
        delete(zi.h1)
        delete(zi.h2)
        delete(zi.h3)
        delete(zi.h4)
end
// WAV Datei auswählen  
[zi.dateiname,zi.pfad]=uigetfile('*.wav','D:\Mdaten');    //WAV Datei wählen
if isequal(zi.dateiname,'');    //Ist eine Date gewählt?
    else
zi.fe=zi.pfad+'\'+zi.dateiname;  //Vollständigen Pfad erstellen
zi.info = wavread(zi.fe,'info');  //WAV Info`s laden
disp('//////////////////////////////////////////////////////////')
disp('WAV-Datei: '+zi.fe); //Ausgabe vollständiger Pfad
disp('Kanäle: '+string(zi.info(2)));   //Ausgabe Anzahl der Kanäle
disp('Samplerate: '+string(zi.info(3)));   //Ausgabe Samplerate
disp('Dateilänge : '+string(zi.info(8)));    //Ausgabe Dateilänge
disp('Laufzeit : '+string(zi.info(8)/zi.info(3))+' Sekunden');    //Laufzeit in Sek.
disp('//////////////////////////////////////////////////////////')
zi.lz=floor(zi.info(8)/zi.info(3)); // lauzeit in sekunden
zi.sr=zi.info(3); //Samplerate der Audiodatei
set(u6,'string',zi.fe);
zi.start1=1;
zi.start2=zi.sr;
zi.so=1;
set(u3,'string',string(zi.so)+'. Sek.');
[zi]=wlana(zi);
[zi]=linkeseite(zi);
[zi]=rechteseite(zi);
end
endfunction
////////////////////////////////////////////////////////////////////////////
function [zi]=wlana(zi)
    //
    if  zi.start2 < zi.info(8) then
    zi.yF=wavread(zi.fe,[zi.start1 zi.start2]);
    zi.yF=zi.yF(1,:);
    zi.yF=zi.yF*zi.v;
    ////
    yFFT=fft(zi.yF,-1,'nonsymmetric'); //Die FFT wird berechnen
    yFFT=yFFT/zi.sr;
    zi.g=abs(yFFT(1))*1000;
    yFFT=yFFT(2:zi.sr-1);
    yFFT1=abs(yFFT); // nur positive Zahlen
    yFFT1=yFFT1*2000; // amplitude normieren
    zi.afft(1:500)=yFFT1(1:500);  //Ergebnisse ins Array
    // powerspektrum
    yFFTL=yFFT.* conj(yFFT);   //Powerspektrum der FFT berechnen
    yFFTL=abs(yFFTL); // realteil
    yFFTL=yFFTL*4000; // amplitude normieren
    zi.afftl(1:500)=yFFTL(1:500);  //Ergebnisse ins Array  
    ////
    end;
endfunction
///////////////////////////////////////////////////////////////////////7/////
function [zi]=linkeseite(zi)
scf(zi.f);
subplot(121);
v=zi.yF;
plot(v,'red','thickness',3);
zi.h1=gce()
zi.l=gca();
zi.l.visible = "on";
zi.l.axes_visible = ["on","on","on"];
zi.l.axes_reverse = ["off","off","off"];
zi.l.auto_ticks = ["off","off","off"];

zi.l.grid = [1,1];
zi.l.grid_thickness = [1,1];
zi.l.grid_style = [1,1];
zi.l.grid_position = "background";

zi.l.title.font_size=2;
zi.l.title.text="WAV Signal";
zi.l.x_label.font_size=2;
zi.l.x_label.text="Zeit in Millisekunden";
zi.l.x_label.visible="on";
zi.l.y_label.font_size=2;
zi.l.y_label.text="Amplitude";
zi.l.y_label.visible="on";

zi.l.auto_scale="off";
// zeitachse
zi.l.x_ticks=tlist(['locations','labels'],[0,4800,9600,14400,19200,24000,28800,33600,38400,43200,48000],["0","100","200","300","400","500","600","700","800","900","1000"]);
// amplitudenachse
zi.l.y_ticks=tlist(['locations','labels'],[-1,-0.9,-0.8,-0.7,-0.6,-0.5,-0.4,-0.3,-0.2,-0.1,0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1],["-1","-0.9","-0.8","-0.7","-0.6","-0.5","-0.4","-0.3","-0.2","-0.1","0","0.1","0.2","0.3","0.4","0.5","0.6","0.7","0.8","0.9","1"]);

zi.l.sub_tics=[9,9,9];

zi.l.box = "back_half";
zi.l.background = -2;
zi.l.tight_limits = ["on","on"];
zi.l.cube_scaling = "on";
zi.l.isoview = "off";
// mit den folgenden einstellungen der drei achsen kann die Anzeige angepasst werden
/////////////////////////////////////////////////////////////////////////////
zh=zi.l.data_bounds;
zh(1,2)=-1;
zh(2,2)=1;
zh(1,1)=1;
zh(2,1)=zi.sr;
zi.l.data_bounds =zh;
zi.l.tag='Links';
//
////////////////////////
endfunction
///////////////////////////////////////////////////////////////////////////
function [zi]=rechteseite(zi)
scf(zi.f);
    subplot(122);
    v=zi.afft;
    w=zi.afftl;
    plot(v,'blue','thickness',3);
    zi.h2=gce()
    bar(0,zi.g,1,'magenta');
    zi.h3=gce()
    plot(w,'red','thickness',3);
    zi.h4=gce()
    //////////////////////
    //
zi.r=gca();
zi.r.visible = "on";
zi.r.axes_visible = ["on","on","on"];
zi.r.axes_reverse = ["off","off","off"];
zi.r.auto_ticks = ["off","off","off"];

zi.r.grid = [1,1];
zi.r.grid_thickness = [1,1];
zi.r.grid_style = [1,1];
zi.r.grid_position = "background";

zi.r.title.font_size=2;
zi.r.title.text="FFT (blau) & FFT-Leistung (rot)";
zi.r.x_label.font_size=2;
zi.r.x_label.text="Frequenz";
zi.r.x_label.visible="on";
zi.r.y_label.font_size=2;
zi.r.y_label.text="Amplitude";
zi.r.y_label.visible="on";

zi.r.auto_scale="off";
// frequenzaschse
zi.r.x_ticks=tlist(['locations','labels'],[0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500],["0","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","160","170","180","190","200","210","220","230","240","250","260","270","280","290","300","310","320","330","340","350","360","370","380","390","400","410","420","430","440","450","460","470","480","490","500"]);
// amplitudenachse
zi.r.y_ticks=tlist(['locations','labels'],[0,100,200,300,400,500,600,700,800,900,1000],["0","0.1","0.2","0.3","0.4","0.5","0.6","0.7","0.8","0.9","1"]);

zi.r.sub_tics=[9,9,9];

zi.r.box = "back_half";
zi.r.background = -2;
zi.r.tight_limits = ["off","off"];
zi.r.cube_scaling = "on";
zi.r.isoview = "off";
// mit den folgenden einstellungen der drei achsen kann die Anzeige angepasst werden
/////////////////////////////////////////////////////////////////////////////
zh=zi.r.data_bounds;
zh(1,2)=0;
zh(2,2)=1000;
zh(1,1)=0;
zh(2,1)=250;
zi.r.data_bounds =zh;
zi.r.tag='Rechts';
///////////////////////////////////////////////////////////////////////
endfunction
//////////////////////////////////////////////////////////////////////
function [zi]=rechts(zi)
    if zi.so==zi.lz then
    else
        delete(zi.h1)
        delete(zi.h2)
        delete(zi.h3)
        delete(zi.h4)
        zi.so=zi.so+1;
        set(u3,'string',string(zi.so)+'. Sek. von '+string(zi.lz));
        zi.start1=zi.start1+zi.sr;
        zi.start2=zi.start2+zi.sr;
        [zi]=wlana(zi);
        [zi]=linkeseite(zi);
        [zi]=rechteseite(zi);
    end    
endfunction
//////////////////////////////////////////////////////////////////////
function [zi]=links(zi)
    if zi.so<=1 then
    else
        delete(zi.h1)
        delete(zi.h2)
        delete(zi.h3)
        delete(zi.h4)
        zi.so=zi.so-1;
        set(u3,'string',string(zi.so)+'. Sek. von '+string(zi.lz));
        zi.start1=zi.start1-zi.sr;
        zi.start2=zi.start2-zi.sr;
        [zi]=wlana(zi);
        [zi]=linkeseite(zi);
        [zi]=rechteseite(zi);
    end
endfunction
///////////////////////////////////////////////////////////////////
function [zi]=verst(zi)
zi.v=u7.value;
if zi.so>0 then
        delete(zi.h1)
        delete(zi.h2)
        delete(zi.h3)
        delete(zi.h4)
        [zi]=wlana(zi);
        [zi]=linkeseite(zi);
        [zi]=rechteseite(zi);
        end
endfunction
 


Und noch eins
Code:
mclose('all');
clear;
xdel();


// 3d grafik
//inline definition (see function)
function my3dlin(v,t1,t2,px,py)
m=size(v); //angezeigter frequenzbereich
//
[xx,yy,zz]=genfac3d(1:m(1),1:m(2),v());
plot3d(xx,yy,list(zz,zz),theta=-20,alpha=16,flag=[-1,2,2]);
//
f=gcf();           //
    f.color_map = jetcolormap(1000); //Colormap festlegen
    f.visible = "on";
    f.figure_position = [px,py];
    f.figure_size = [1400,900];
    f.figure_name=t1;
    //////////////////////
    //
////////////////////////////////////////////////////////
//Handle of type "Plot3d" with properties:
//========================================
/////////////////////////////////////////////////////////
a=gca();
a.visible = "on";
a.axes_visible = ["on","on","on"];
a.axes_reverse = ["on","off","off"];
a.auto_ticks = ["off","off","off"];

a.grid = [1,1,1];
a.grid_thickness = [1,1,1];
a.grid_style = [1,1,1];
a.grid_position = "background";

a.title.font_size=2;
a.title.text=t2;
a.x_label.font_size=2;
a.x_label.text="Sekunden";
a.x_label.visible="on";
a.y_label.font_size=2;
a.y_label.text="Frequenz";
a.y_label.visible="on";
a.z_label.font_size=2;
a.z_label.text="Amplitude";
a.z_label.visible="on";

a.auto_scale="off";
// sekundenachse
a.x_ticks=tlist(['locations','labels'],[1,40,80,120,160,200,240,280,320,360,400,440,480,520,560,600,640,680,720,760,800,840,880,920,960,1000,1040,1080,1120,1160,1200,1240,1280,1320,1360,1400,1440,1480,1520,1560,1600,1640,1680,1720,1760,1800,1840,1880,1920,1960,2000],["0","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","160","170","180","190","200","210","220","230","240","250","260","270","280","290","300","310","320","330","340","350","360","370","380","390","400","410","420","430","440","450","460","470","480","490","500"]);
// frequenzaschse
a.y_ticks=tlist(['locations','labels'],[0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500],["0","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","160","170","180","190","200","210","220","230","240","250","260","270","280","290","300","310","320","330","340","350","360","370","380","390","400","410","420","430","440","450","460","470","480","490","500"]);
// amplitudenachse
a.z_ticks=tlist(['locations','labels'],[0,100,200,300,400,500,600,700,800,900,1000],["0","100","200","300","400","500","600","700","800","900","1000"]);

a.sub_tics=[9,9,9];

a.box = "back_half";
//a.background = color(255,248,220);
a.background = -2;
a.tight_limits = ["on","off","off"];
a.cube_scaling = "on";
a.isoview = "off";
a.rotation_angles = [9.5,4.25];
// mit den folgenden einstellungen der drei achsen kann die Anzeige angepasst werden
/////////////////////////////////////////////////////////////////////////////
zh=a.data_bounds;
// zeitachse
//zh(1,1)=1;
//zh(2,1)=199;
// frequenzachse
//zh(1,2)=0;
//zh(2,2)=150;
// amplitudenachse
zh(1,3)=1;
zh(2,3)=1000;
a.data_bounds =zh;
//
//a.log_flags = "nnn"
/////////////////////////////////////////////////////////////////////////////
//
b=gce;
//b.parent: Axes
//b.children: []
//b.visible = "on"
//b.surface_mode = "on"
//b.foreground = -1
//b.thickness = 1
//b.mark_mode = "off"
//b.mark_style = 0
//b.mark_size_unit = "tabulated"
//b.mark_size = 0
//b.mark_foreground = -1
//b.mark_background = 0
//b.data.x = matrix 1x712
//b.data.y = matrix 1x500
//b.data.z = matrix 4x1000
//b.color_mode = -1
//b.color_flag = 1
//b.hiddencolor = 4
//b.clip_state = "clipgrf"
//b.clip_box = []
//b.ambient_color = [1,1,1]
//b.diffuse_color = [1,1,1]
//b.specular_color = [1,1,1]
//b.use_color_material = "on"
//b.material_shininess = 2
//b.user_data = []
//b.tag =
endfunction
//////////////////////////////////////////////////////////////////////////
function my3dlog(v,t1,t2,px,py)
    m=size(v); //angezeigter frequenzbereich
//
[xx,yy,zz]=genfac3d(1:m(1),1:m(2),v());
plot3d(xx,yy,list(zz,zz),theta=-20,alpha=16,flag=[-1,2,2]);
//
f=gcf();           //
    f.color_map = jetcolormap(1000); //Colormap festlegen
    //colorbar(1,1000,[0 1000],fmt='%.1f');
    f.visible = "on";
    f.figure_position = [px,py];
    f.figure_size = [1400,900];
    f.figure_name=t1;
    //////////////////////
    //
////////////////////////////////////////////////////////
//Handle of type "Plot3d" with properties:
//========================================
/////////////////////////////////////////////////////////
a=gca();
a.visible = "on";
a.axes_visible = ["on","on","on"];
a.axes_reverse = ["on","off","off"];
a.auto_ticks = ["off","off","off"];

a.grid = [1,1,1];
a.grid_thickness = [1,1,1];
a.grid_style = [1,1,1];
a.grid_position = "background";

a.title.font_size=2;
a.title.text=t2;
a.x_label.font_size=2;
a.x_label.text="Sekunden";
a.x_label.visible="on";
a.y_label.font_size=2;
a.y_label.text="Frequenz";
a.y_label.visible="on";
a.z_label.font_size=2;
a.z_label.text="Amplitude";
a.z_label.visible="on";

a.auto_scale="off";
// sekundenachse
a.x_ticks=tlist(['locations','labels'],[1,40,80,120,160,200,240,280,320,360,400,440,480,520,560,600,640,680,720,760,800,840,880,920,960,1000,1040,1080,1120,1160,1200,1240,1280,1320,1360,1400,1440,1480,1520,1560,1600,1640,1680,1720,1760,1800,1840,1880,1920,1960,2000],["0","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","160","170","180","190","200","210","220","230","240","250","260","270","280","290","300","310","320","330","340","350","360","370","380","390","400","410","420","430","440","450","460","470","480","490","500"]);
// frequenzaschse
a.y_ticks=tlist(['locations','labels'],[0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500],["0","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","160","170","180","190","200","210","220","230","240","250","260","270","280","290","300","310","320","330","340","350","360","370","380","390","400","410","420","430","440","450","460","470","480","490","500"]);
// amplitudenachse
a.z_ticks=tlist(['locations','labels'],[0,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000],["-100","-95","-90","-85","-80","-75","-70","-65","-60","-55","-50","-45","-40","-35","-30","-25","-20","-15","-10","-5","-0"]);

a.sub_tics=[9,9,4];

a.box = "back_half";
//a.background = color(255,248,220);
a.background = -2;
a.tight_limits = ["on","off","off"];
a.cube_scaling = "on";
a.isoview = "off";
//a.rotation_angles = [9.5,4.25];
a.rotation_angles = [0.1,0];
// mit den folgenden einstellungen der drei achsen kann die Anzeige angepasst werden
/////////////////////////////////////////////////////////////////////////////
zh=a.data_bounds;
// zeitachse
//zh(1,1)=1;
//zh(2,1)=199;
// frequenzachse
//zh(1,2)=0;
//zh(2,2)=150;
// amplitudenachse
zh(1,3)=1;
zh(2,3)=1000;
a.data_bounds =zh;
//
//a.log_flags = "nnn"
/////////////////////////////////////////////////////////////////////////////
//
b=gce;
//b.parent: Axes
//b.children: []
//b.visible = "on"
//b.surface_mode = "on"
//b.foreground = -1
//b.thickness = 1
//b.mark_mode = "off"
//b.mark_style = 0
//b.mark_size_unit = "tabulated"
//b.mark_size = 0
//b.mark_foreground = -1
//b.mark_background = 0
//b.data.x = matrix 1x712
//b.data.y = matrix 1x500
//b.data.z = matrix 4x1000
//b.color_mode = -1
//b.color_flag = 1
//b.hiddencolor = 4
//b.clip_state = "clipgrf"
//b.clip_box = []
//b.ambient_color = [1,1,1]
//b.diffuse_color = [1,1,1]
//b.specular_color = [1,1,1]
//b.use_color_material = "on"
//b.material_shininess = 2
//b.user_data = []
//b.tag =
endfunction
//////////////////////////////////////////////////////////////////////////
function my2dlin(v,t1,t2,px,py); // linear 2d
    m=size(v); //angezeigter frequenzbereich
//
    plot(v,'blue','thickness',3);
    f=gcf();           //
    f.color_map = jetcolormap(1000); //Colormap festlegen
    f.visible = "on";
    f.figure_position = [px,py];
    f.figure_size = [1400,900];
    f.figure_name=t1;
    f.BackgroundColor=[1 1 1];
    //////////////////////
    //
////////////////////////////////////////////////////////
//Handle of type "Plot3d" with properties:
//========================================
/////////////////////////////////////////////////////////
a=gca();
a.visible = "on";
a.axes_visible = ["on","on","on"];
a.axes_reverse = ["off","off","off"];
a.auto_ticks = ["off","off","off"];

a.grid = [1,1];
a.grid_thickness = [1,1];
a.grid_style = [1,1];
a.grid_position = "background";

a.title.font_size=2;
a.title.text=t2;
a.x_label.font_size=2;
a.x_label.text="Frequenz";
a.x_label.visible="on";
a.y_label.font_size=2;
a.y_label.text="Amplitude";
a.y_label.visible="on";

a.auto_scale="off";
// frequenzaschse
a.x_ticks=tlist(['locations','labels'],[0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500],["0","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","160","170","180","190","200","210","220","230","240","250","260","270","280","290","300","310","320","330","340","350","360","370","380","390","400","410","420","430","440","450","460","470","480","490","500"]);
// amplitudenachse
a.y_ticks=tlist(['locations','labels'],[0,100,200,300,400,500,600,700,800,900,1000],["0","100","200","300","400","500","600","700","800","900","1000"]);

a.sub_tics=[9,9,9];

a.box = "back_half";
a.background = -2;
a.tight_limits = ["off","off"];
a.cube_scaling = "on";
a.isoview = "off";
// mit den folgenden einstellungen der drei achsen kann die Anzeige angepasst werden
/////////////////////////////////////////////////////////////////////////////
zh=a.data_bounds;
zh(1,2)=1;
zh(2,2)=1000;
a.data_bounds =zh;
endfunction
///////////////////////////////////////////////////////////////////////
function my2dlog(v,t1,t2,px,py); // linear 2d
    m=size(v); //angezeigter frequenzbereich
//
    plot(v,'blue','thickness',3);
    f=gcf();           //
    f.color_map = jetcolormap(1000); //Colormap festlegen
    f.visible = "on";
    f.figure_position = [px,py];
    f.figure_size = [1400,900];
    f.figure_name=t1;
    f.BackgroundColor=[1 1 1];
    //////////////////////
    //
////////////////////////////////////////////////////////
//Handle of type "Plot3d" with properties:
//========================================
/////////////////////////////////////////////////////////
a=gca();
a.visible = "on";
a.axes_visible = ["on","on","on"];
a.axes_reverse = ["off","off","off"];
a.auto_ticks = ["off","off","off"];

a.grid = [1,1];
a.grid_thickness = [1,1];
a.grid_style = [1,1];
a.grid_position = "background";

a.title.font_size=2;
a.title.text=t2;
a.x_label.font_size=2;
a.x_label.text="Frequenz";
a.x_label.visible="on";
a.y_label.font_size=2;
a.y_label.text="Amplitude";
a.y_label.visible="on";

a.auto_scale="off";
// frequenzaschse
a.x_ticks=tlist(['locations','labels'],[0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500],["0","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","160","170","180","190","200","210","220","230","240","250","260","270","280","290","300","310","320","330","340","350","360","370","380","390","400","410","420","430","440","450","460","470","480","490","500"]);
// amplitudenachse
a.y_ticks=tlist(['locations','labels'],[0,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000],["-100","-95","-90","-85","-80","-75","-70","-65","-60","-55","-50","-45","-40","-35","-30","-25","-20","-15","-10","-5","-0"]);

a.sub_tics=[9,9,9];

a.box = "back_half";
a.background = -2;
a.tight_limits = ["off","off"];
a.cube_scaling = "on";
a.isoview = "off";
zh=a.data_bounds;
zh(1,2)=1;
zh(2,2)=1000;
a.data_bounds =zh;
endfunction
////////////////////////////////////////////////////////////////////////
// Analyse2-Show2
///////////////////////////////////////////////////////////////////////
mode(0);
// Hier werden Analyse-Daten angezeigt
// Die Daten enthalten die Variablen
// 'afft' 'afftm' 'afftg' 'afftl' 'afftlm' 'afftlg'
// afft > Ergebnisse der FFT
// afftm > Mittelwerte der FFT
// afftg > Ergebnisse der FFT logarythmisch
// afftl > Leitungsspektrum der FFT
// afftlm > Mittelwerte des Leistungsspektrum
// afftlg > Leistungsspektrum logarythmisch
// dat Datei auswählen  
[dateiname,pfad]=uigetfile('*.dat','D:\Mdaten');    //dat Datei wählen
if isequal(dateiname,0);    //Ist eine Date gewählt?
    //
else
    //
    fe=pfad+'\'+dateiname;  //Vollständigen Pfad erstellen
    load(fe);
    /////////////////////////////////////////////
    disp('////////////////////////////////////////////////////////////')
    disp('Scilab-Datei: '+ fe); //Ausgabe vollständiger Pfad
    disp('////////////////////////////////////////////////////////////')
//
h1=scf(1);
scf(h1);
// fft
    disp('Zeige Fast Fourier Transformation 3d');
    v=afft(:,1:500);
    v=v*1000;
    t1='Fenster 1';
    t2='FFT';
    px=10;
    py=10;
    my3dlin(v,t1,t2,px,py);
// fft mittelwert
h2=scf(2);
scf(h2);
    disp('Zeige Fast Fourier Transformation Mittelwerte 2d');
    v=afftm(:,1:500);
    v=v*1000;
    t1='Fenster 2';
    t2='FFT Mittelwerte';
    px=20;
    py=20;
    my2dlin(v,t1,t2,px,py);
// fft logarythmisch
h3=scf(3);
scf(h3);
    disp('Zeige Fast Fourier Transformation logarythmisch 3d');
    v=afftg(:,1:500);
    v=v*10+1000;
    t1='Fenster 3';
    t2='FFT log';
    px=30;
    py=30;
    my3dlog(v,t1,t2,px,py);  
//
h4=scf(4);
scf(h4);
    disp('Zeige Fast Fourier Transformation logarythmisch Mittelwerte 2d');
    v=afftgm(:,1:500);
    v=v*10+1000;
    t1='Fenster 4';
    t2='FFT log Mittelwerte';
    px=40;
    py=40;
    my2dlog(v,t1,t2,px,py);
//
h5=scf(5);
scf(h5);
    disp('Zeige Leistungsspektrum 3d');
    v=afftl(:,1:500);
    v=v*1000;
    t1='Fenster 5';
    t2='Leistungsspektrum';
    px=50;
    py=50;
    my3dlin(v,t1,t2,px,py);
//
h6=scf(6);
scf(h6);
    disp('Zeige Leistungsspektrum Mittelwerte 2d');
    v=afftlm(:,1:500);
    v=v*1000;
    t1='Fenster 6';
    t2='Leistungsspektrum Mittelwerte';
    px=60;
    py=60;
    my2dlin(v,t1,t2,px,py);
//    
h7=scf(7);
scf(h7);
    disp('Zeige Leistungsspektrum logarythmisch 3d');
    v=afftlg(:,1:500);
    v=v*10+1000;
    t1='Fenster 7';
    t2='Leistungsspektrum log';
    px=70;
    py=70;
    my3dlog(v,t1,t2,px,py);
//
h8=scf(8);
scf(h8);
    disp('Zeige Leistungsspektrum logarythmisch Mittelwerte 2d');
    v=afftlgm(:,1:500);
    v=v*10+1000;
    t1='Fenster 8';
    t2='Leistungsspektrum log Mittelwerte';
    px=80;
    py=80;
    my2dlog(v,t1,t2,px,py);
//




end
//subplot(10,1,1);
//plot(afftlm(1:100));
//gca.grid = [1,1,1];
//gca.x_ticks=tlist(['locations','labels'],[0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100],["0","5","10","15","20","25","30","35","40","45","50","55","60","65","70","75","80","85","90","95","100"]);
//gca.sub_tics=[4,9];
//gca.x_location='top';
 
Private Nachricht senden Benutzer-Profile anzeigen
 
brummfritz
Forum-Anfänger

Forum-Anfänger


Beiträge: 20
Anmeldedatum: 01.09.16
Wohnort: Düsseldorf
Version: Matlab R2015b
     Beitrag Verfasst am: 16.06.2017, 00:16     Titel:
  Antworten mit Zitat      
Bei dem zweiten Skript aus dem vorigen Beitrag kann es zu Störungen im Ablauf kommen.
Der Grund, bei dem Wechsel zwischen linearer und logarithmischer Darstellung im Plot kann es zu Irritationen kommen.
Daher habe ich die Darstellungen in zwei Skripte aufgeteilt, einmal lineare und einmal logarithmische Plots.

Die Programme analysieren Wav Dateien. In deinem fall muss lediglich die Eingabe und Samplefrequenz angepasst werden. Bei Wav Dateien wird die maximale Amplitude bei dem Eingangssignal als 1 angesehen.

Also mit einigen Anpassungen im Skript kann dein Problem gelöst werden.

Log Darstellung

Code:
mclose('all');
clear;
xdel();


// 3d grafik
//inline definition (see function)
function my3dlin(v,t1,t2,px,py)
m=size(v); //angezeigter frequenzbereich
//
[xx,yy,zz]=genfac3d(1:m(1),1:m(2),v());
plot3d(xx,yy,list(zz,zz),theta=-20,alpha=16,flag=[-1,2,2]);
//
f=gcf();           //
    f.color_map = jetcolormap(1000); //Colormap festlegen
    f.visible = "on";
    f.figure_position = [px,py];
    f.figure_size = [1400,900];
    f.figure_name=t1;
    //////////////////////
    //
////////////////////////////////////////////////////////
//Handle of type "Plot3d" with properties:
//========================================
/////////////////////////////////////////////////////////
a=gca();
a.visible = "on";
a.axes_visible = ["on","on","on"];
a.axes_reverse = ["on","off","off"];
a.auto_ticks = ["off","off","off"];

a.grid = [1,1,1];
a.grid_thickness = [1,1,1];
a.grid_style = [1,1,1];
a.grid_position = "background";

a.title.font_size=2;
a.title.text=t2;
a.x_label.font_size=2;
a.x_label.text="Sekunden";
a.x_label.visible="on";
a.y_label.font_size=2;
a.y_label.text="Frequenz";
a.y_label.visible="on";
a.z_label.font_size=2;
a.z_label.text="Amplitude";
a.z_label.visible="on";

a.auto_scale="off";
// sekundenachse
a.x_ticks=tlist(['locations','labels'],[1,40,80,120,160,200,240,280,320,360,400,440,480,520,560,600,640,680,720,760,800,840,880,920,960,1000,1040,1080,1120,1160,1200,1240,1280,1320,1360,1400,1440,1480,1520,1560,1600,1640,1680,1720,1760,1800,1840,1880,1920,1960,2000],["0","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","160","170","180","190","200","210","220","230","240","250","260","270","280","290","300","310","320","330","340","350","360","370","380","390","400","410","420","430","440","450","460","470","480","490","500"]);
// frequenzaschse
a.y_ticks=tlist(['locations','labels'],[0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500],["0","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","160","170","180","190","200","210","220","230","240","250","260","270","280","290","300","310","320","330","340","350","360","370","380","390","400","410","420","430","440","450","460","470","480","490","500"]);
// amplitudenachse
a.z_ticks=tlist(['locations','labels'],[0,100,200,300,400,500,600,700,800,900,1000],["0","100","200","300","400","500","600","700","800","900","1000"]);

a.sub_tics=[9,9,9];

a.box = "back_half";
//a.background = color(255,248,220);
a.background = -2;
a.tight_limits = ["on","off","off"];
a.cube_scaling = "on";
a.isoview = "off";
a.rotation_angles = [9.5,4.25];
// mit den folgenden einstellungen der drei achsen kann die Anzeige angepasst werden
/////////////////////////////////////////////////////////////////////////////
zh=a.data_bounds;
// zeitachse
//zh(1,1)=1;
//zh(2,1)=199;
// frequenzachse
//zh(1,2)=0;
//zh(2,2)=150;
// amplitudenachse
zh(1,3)=1;
zh(2,3)=1000;
a.data_bounds =zh;
//
//a.log_flags = "nnn"
/////////////////////////////////////////////////////////////////////////////
//
b=gce;
//b.parent: Axes
//b.children: []
//b.visible = "on"
//b.surface_mode = "on"
//b.foreground = -1
//b.thickness = 1
//b.mark_mode = "off"
//b.mark_style = 0
//b.mark_size_unit = "tabulated"
//b.mark_size = 0
//b.mark_foreground = -1
//b.mark_background = 0
//b.data.x = matrix 1x712
//b.data.y = matrix 1x500
//b.data.z = matrix 4x1000
//b.color_mode = -1
//b.color_flag = 1
//b.hiddencolor = 4
//b.clip_state = "clipgrf"
//b.clip_box = []
//b.ambient_color = [1,1,1]
//b.diffuse_color = [1,1,1]
//b.specular_color = [1,1,1]
//b.use_color_material = "on"
//b.material_shininess = 2
//b.user_data = []
//b.tag =
endfunction
//////////////////////////////////////////////////////////////////////////
function my3dlog(v,t1,t2,px,py)
    m=size(v); //angezeigter frequenzbereich
//
[xx,yy,zz]=genfac3d(1:m(1),1:m(2),v());
plot3d(xx,yy,list(zz,zz),theta=-20,alpha=16,flag=[-1,2,2]);
//
f=gcf();           //
    f.color_map = jetcolormap(1000); //Colormap festlegen
    //colorbar(1,1000,[0 1000],fmt='%.1f');
    f.visible = "on";
    f.figure_position = [px,py];
    f.figure_size = [1400,900];
    f.figure_name=t1;
    //////////////////////
    //
////////////////////////////////////////////////////////
//Handle of type "Plot3d" with properties:
//========================================
/////////////////////////////////////////////////////////
a=gca();
a.visible = "on";
a.axes_visible = ["on","on","on"];
a.axes_reverse = ["on","off","off"];
a.auto_ticks = ["off","off","off"];

a.grid = [1,1,1];
a.grid_thickness = [1,1,1];
a.grid_style = [1,1,1];
a.grid_position = "background";

a.title.font_size=2;
a.title.text=t2;
a.x_label.font_size=2;
a.x_label.text="Sekunden";
a.x_label.visible="on";
a.y_label.font_size=2;
a.y_label.text="Frequenz";
a.y_label.visible="on";
a.z_label.font_size=2;
a.z_label.text="Amplitude";
a.z_label.visible="on";

a.auto_scale="off";
// sekundenachse
a.x_ticks=tlist(['locations','labels'],[1,40,80,120,160,200,240,280,320,360,400,440,480,520,560,600,640,680,720,760,800,840,880,920,960,1000,1040,1080,1120,1160,1200,1240,1280,1320,1360,1400,1440,1480,1520,1560,1600,1640,1680,1720,1760,1800,1840,1880,1920,1960,2000],["0","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","160","170","180","190","200","210","220","230","240","250","260","270","280","290","300","310","320","330","340","350","360","370","380","390","400","410","420","430","440","450","460","470","480","490","500"]);
// frequenzaschse
a.y_ticks=tlist(['locations','labels'],[0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500],["0","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","160","170","180","190","200","210","220","230","240","250","260","270","280","290","300","310","320","330","340","350","360","370","380","390","400","410","420","430","440","450","460","470","480","490","500"]);
// amplitudenachse
a.z_ticks=tlist(['locations','labels'],[0,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000],["-100","-95","-90","-85","-80","-75","-70","-65","-60","-55","-50","-45","-40","-35","-30","-25","-20","-15","-10","-5","-0"]);

a.sub_tics=[9,9,4];

a.box = "back_half";
//a.background = color(255,248,220);
a.background = -2;
a.tight_limits = ["on","off","off"];
a.cube_scaling = "on";
a.isoview = "off";
//a.rotation_angles = [9.5,4.25];
a.rotation_angles = [0.1,0];
// mit den folgenden einstellungen der drei achsen kann die Anzeige angepasst werden
/////////////////////////////////////////////////////////////////////////////
zh=a.data_bounds;
// zeitachse
//zh(1,1)=1;
//zh(2,1)=199;
// frequenzachse
//zh(1,2)=0;
//zh(2,2)=150;
// amplitudenachse
zh(1,3)=1;
zh(2,3)=1000;
a.data_bounds =zh;
//
//a.log_flags = "nnn"
/////////////////////////////////////////////////////////////////////////////
//
b=gce;
//b.parent: Axes
//b.children: []
//b.visible = "on"
//b.surface_mode = "on"
//b.foreground = -1
//b.thickness = 1
//b.mark_mode = "off"
//b.mark_style = 0
//b.mark_size_unit = "tabulated"
//b.mark_size = 0
//b.mark_foreground = -1
//b.mark_background = 0
//b.data.x = matrix 1x712
//b.data.y = matrix 1x500
//b.data.z = matrix 4x1000
//b.color_mode = -1
//b.color_flag = 1
//b.hiddencolor = 4
//b.clip_state = "clipgrf"
//b.clip_box = []
//b.ambient_color = [1,1,1]
//b.diffuse_color = [1,1,1]
//b.specular_color = [1,1,1]
//b.use_color_material = "on"
//b.material_shininess = 2
//b.user_data = []
//b.tag =
endfunction
//////////////////////////////////////////////////////////////////////////
function my2dlin(v,t1,t2,px,py); // linear 2d
    m=size(v); //angezeigter frequenzbereich
//
    plot(v,'blue','thickness',3);
    f=gcf();           //
    f.color_map = jetcolormap(1000); //Colormap festlegen
    f.visible = "on";
    f.figure_position = [px,py];
    f.figure_size = [1400,900];
    f.figure_name=t1;
    f.BackgroundColor=[1 1 1];
    //////////////////////
    //
////////////////////////////////////////////////////////
//Handle of type "Plot3d" with properties:
//========================================
/////////////////////////////////////////////////////////
a=gca();
a.visible = "on";
a.axes_visible = ["on","on","on"];
a.axes_reverse = ["off","off","off"];
a.auto_ticks = ["off","off","off"];

a.grid = [1,1];
a.grid_thickness = [1,1];
a.grid_style = [1,1];
a.grid_position = "background";

a.title.font_size=2;
a.title.text=t2;
a.x_label.font_size=2;
a.x_label.text="Frequenz";
a.x_label.visible="on";
a.y_label.font_size=2;
a.y_label.text="Amplitude";
a.y_label.visible="on";

a.auto_scale="off";
// frequenzaschse
a.x_ticks=tlist(['locations','labels'],[0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500],["0","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","160","170","180","190","200","210","220","230","240","250","260","270","280","290","300","310","320","330","340","350","360","370","380","390","400","410","420","430","440","450","460","470","480","490","500"]);
// amplitudenachse
a.y_ticks=tlist(['locations','labels'],[0,100,200,300,400,500,600,700,800,900,1000],["0","100","200","300","400","500","600","700","800","900","1000"]);

a.sub_tics=[9,9,9];

a.box = "back_half";
a.background = -2;
a.tight_limits = ["off","off"];
a.cube_scaling = "on";
a.isoview = "off";
// mit den folgenden einstellungen der drei achsen kann die Anzeige angepasst werden
/////////////////////////////////////////////////////////////////////////////
zh=a.data_bounds;
zh(1,2)=1;
zh(2,2)=1000;
a.data_bounds =zh;
endfunction
///////////////////////////////////////////////////////////////////////
function my2dlog(v,t1,t2,px,py); // linear 2d
    m=size(v); //angezeigter frequenzbereich
//
    plot(v,'blue','thickness',3);
    f=gcf();           //
    f.color_map = jetcolormap(1000); //Colormap festlegen
    f.visible = "on";
    f.figure_position = [px,py];
    f.figure_size = [1400,900];
    f.figure_name=t1;
    f.BackgroundColor=[1 1 1];
    //////////////////////
    //
////////////////////////////////////////////////////////
//Handle of type "Plot3d" with properties:
//========================================
/////////////////////////////////////////////////////////
a=gca();
a.visible = "on";
a.axes_visible = ["on","on","on"];
a.axes_reverse = ["off","off","off"];
a.auto_ticks = ["off","off","off"];

a.grid = [1,1];
a.grid_thickness = [1,1];
a.grid_style = [1,1];
a.grid_position = "background";

a.title.font_size=2;
a.title.text=t2;
a.x_label.font_size=2;
a.x_label.text="Frequenz";
a.x_label.visible="on";
a.y_label.font_size=2;
a.y_label.text="Amplitude";
a.y_label.visible="on";

a.auto_scale="off";
// frequenzaschse
a.x_ticks=tlist(['locations','labels'],[0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500],["0","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","160","170","180","190","200","210","220","230","240","250","260","270","280","290","300","310","320","330","340","350","360","370","380","390","400","410","420","430","440","450","460","470","480","490","500"]);
// amplitudenachse
a.y_ticks=tlist(['locations','labels'],[0,50,100,150,200,250,300,350,400,450,500,550,600,650,700,750,800,850,900,950,1000],["-100","-95","-90","-85","-80","-75","-70","-65","-60","-55","-50","-45","-40","-35","-30","-25","-20","-15","-10","-5","-0"]);

a.sub_tics=[9,9,9];

a.box = "back_half";
a.background = -2;
a.tight_limits = ["off","off"];
a.cube_scaling = "on";
a.isoview = "off";
zh=a.data_bounds;
zh(1,2)=1;
zh(2,2)=1000;
a.data_bounds =zh;
endfunction
////////////////////////////////////////////////////////////////////////
// Analyse2-Show2
///////////////////////////////////////////////////////////////////////
mode(0);
// Hier werden Analyse-Daten angezeigt
// Die Daten enthalten die Variablen
// 'afft' 'afftm' 'afftg' 'afftl' 'afftlm' 'afftlg'
// afft > Ergebnisse der FFT
// afftm > Mittelwerte der FFT
// afftg > Ergebnisse der FFT logarythmisch
// afftl > Leitungsspektrum der FFT
// afftlm > Mittelwerte des Leistungsspektrum
// afftlg > Leistungsspektrum logarythmisch
// dat Datei auswählen  
[dateiname,pfad]=uigetfile('*.dat','D:\Mdaten');    //dat Datei wählen
if isequal(dateiname,0);    //Ist eine Date gewählt?
    //
else
    //
    fe=pfad+'\'+dateiname;  //Vollständigen Pfad erstellen
    load(fe);
    /////////////////////////////////////////////
    disp('////////////////////////////////////////////////////////////')
    disp('Scilab-Datei: '+ fe); //Ausgabe vollständiger Pfad
    disp('////////////////////////////////////////////////////////////')
//
// fft logarythmisch
h3=scf(3);
scf(h3);
    disp('Zeige Fast Fourier Transformation logarythmisch 3d');
    v=afftg(:,1:500);
    v=v*10+1000;
    t1='Fenster 3';
    t2='FFT log';
    px=10;
    py=10;
    my3dlog(v,t1,t2,px,py);  
//
h4=scf(4);
scf(h4);
    disp('Zeige Fast Fourier Transformation logarythmisch Mittelwerte 2d');
    v=afftgm(:,1:500);
    v=v*10+1000;
    t1='Fenster 4';
    t2='FFT log Mittelwerte';
    px=20;
    py=20;
    my2dlog(v,t1,t2,px,py);
//
//    
h7=scf(7);
scf(h7);
    disp('Zeige Leistungsspektrum logarythmisch 3d');
    v=afftlg(:,1:500);
    v=v*10+1000;
    t1='Fenster 7';
    t2='Leistungsspektrum log';
    px=30;
    py=30;
    my3dlog(v,t1,t2,px,py);
//
h8=scf(8);
scf(h8);
    disp('Zeige Leistungsspektrum logarythmisch Mittelwerte 2d');
    v=afftlgm(:,1:500);
    v=v*10+1000;
    t1='Fenster 8';
    t2='Leistungsspektrum log Mittelwerte';
    px=40;
    py=40;
    my2dlog(v,t1,t2,px,py);
//




end
//subplot(10,1,1);
//plot(afftlm(1:100));
//gca.grid = [1,1,1];
//gca.x_ticks=tlist(['locations','labels'],[0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100],["0","5","10","15","20","25","30","35","40","45","50","55","60","65","70","75","80","85","90","95","100"]);
//gca.sub_tics=[4,9];
//gca.x_location='top';
 


Lin Darstellung

Code:
mclose('all');
clear;
xdel();


// 3d grafik
//inline definition (see function)
function my3dlin(v,t1,t2,px,py,cm)
m=size(v); //angezeigter frequenzbereich
//
[xx,yy,zz]=genfac3d(1:m(1),1:m(2),v());
plot3d(xx,yy,list(zz,zz),theta=-20,alpha=16,flag=[-1,2,2]);
//
f=gcf();           //
    f.color_map = jetcolormap(cm); //Colormap festlegen
    f.visible = "on";
    f.figure_position = [px,py];
    f.figure_size = [1400,900];
    f.figure_name=t1;
    //////////////////////
    //
////////////////////////////////////////////////////////
//Handle of type "Plot3d" with properties:
//========================================
/////////////////////////////////////////////////////////
a=gca();
a.visible = "on";
a.axes_visible = ["on","on","on"];
a.axes_reverse = ["on","off","off"];
a.auto_ticks = ["off","off","off"];

a.grid = [1,1,1];
a.grid_thickness = [1,1,1];
a.grid_style = [1,1,1];
a.grid_position = "background";

a.title.font_size=2;
a.title.text=t2;
a.x_label.font_size=2;
a.x_label.text="Sekunden";
a.x_label.visible="on";
a.y_label.font_size=2;
a.y_label.text="Frequenz";
a.y_label.visible="on";
a.z_label.font_size=2;
a.z_label.text="Amplitude";
a.z_label.visible="on";

a.auto_scale="off";
// sekundenachse
a.x_ticks=tlist(['locations','labels'],[1,40,80,120,160,200,240,280,320,360,400,440,480,520,560,600,640,680,720,760,800,840,880,920,960,1000,1040,1080,1120,1160,1200,1240,1280,1320,1360,1400,1440,1480,1520,1560,1600,1640,1680,1720,1760,1800,1840,1880,1920,1960,2000],["0","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","160","170","180","190","200","210","220","230","240","250","260","270","280","290","300","310","320","330","340","350","360","370","380","390","400","410","420","430","440","450","460","470","480","490","500"]);
// frequenzaschse
a.y_ticks=tlist(['locations','labels'],[0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500],["0","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","160","170","180","190","200","210","220","230","240","250","260","270","280","290","300","310","320","330","340","350","360","370","380","390","400","410","420","430","440","450","460","470","480","490","500"]);
// amplitudenachse
a.z_ticks=tlist(['locations','labels'],[0,100,200,300,400,500,600,700,800,900,1000],["0","100","200","300","400","500","600","700","800","900","1000"]);

a.sub_tics=[9,9,9];

a.box = "back_half";
//a.background = color(255,248,220);
a.background = -2;
a.tight_limits = ["on","off","off"];
a.cube_scaling = "on";
a.isoview = "off";
a.rotation_angles = [9.5,4.25];
// mit den folgenden einstellungen der drei achsen kann die Anzeige angepasst werden
/////////////////////////////////////////////////////////////////////////////
zh=a.data_bounds;
// zeitachse
//zh(1,1)=1;
//zh(2,1)=199;
// frequenzachse
//zh(1,2)=0;
//zh(2,2)=150;
// amplitudenachse
zh(1,3)=0;
zh(2,3)=1000;
a.data_bounds =zh;
//
//a.log_flags = "nnn"
/////////////////////////////////////////////////////////////////////////////
//
b=gce;
//b.parent: Axes
//b.children: []
//b.visible = "on"
//b.surface_mode = "on"
//b.foreground = -1
//b.thickness = 1
//b.mark_mode = "off"
//b.mark_style = 0
//b.mark_size_unit = "tabulated"
//b.mark_size = 0
//b.mark_foreground = -1
//b.mark_background = 0
//b.data.x = matrix 1x712
//b.data.y = matrix 1x500
//b.data.z = matrix 4x1000
//b.color_mode = -1
//b.color_flag = 1
//b.hiddencolor = 4
//b.clip_state = "clipgrf"
//b.clip_box = []
//b.ambient_color = [1,1,1]
//b.diffuse_color = [1,1,1]
//b.specular_color = [1,1,1]
//b.use_color_material = "on"
//b.material_shininess = 2
//b.user_data = []
//b.tag =
endfunction
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
function my2dlin(v,t1,t2,px,py); // linear 2d
    m=size(v); //angezeigter frequenzbereich
//
    plot(v,'blue','thickness',3);
    f=gcf();           //
    f.color_map = jetcolormap(1000); //Colormap festlegen
    f.visible = "on";
    f.figure_position = [px,py];
    f.figure_size = [1400,900];
    f.figure_name=t1;
    f.BackgroundColor=[1 1 1];
    //////////////////////
    //
////////////////////////////////////////////////////////
//Handle of type "Plot3d" with properties:
//========================================
/////////////////////////////////////////////////////////
a=gca();
a.visible = "on";
a.axes_visible = ["on","on","on"];
a.axes_reverse = ["off","off","off"];
a.auto_ticks = ["off","off","off"];

a.grid = [1,1];
a.grid_thickness = [1,1];
a.grid_style = [1,1];
a.grid_position = "background";

a.title.font_size=2;
a.title.text=t2;
a.x_label.font_size=2;
a.x_label.text="Frequenz";
a.x_label.visible="on";
a.y_label.font_size=2;
a.y_label.text="Amplitude";
a.y_label.visible="on";

a.auto_scale="off";
// frequenzaschse
a.x_ticks=tlist(['locations','labels'],[0,10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200,210,220,230,240,250,260,270,280,290,300,310,320,330,340,350,360,370,380,390,400,410,420,430,440,450,460,470,480,490,500],["0","10","20","30","40","50","60","70","80","90","100","110","120","130","140","150","160","170","180","190","200","210","220","230","240","250","260","270","280","290","300","310","320","330","340","350","360","370","380","390","400","410","420","430","440","450","460","470","480","490","500"]);
// amplitudenachse
a.y_ticks=tlist(['locations','labels'],[0,100,200,300,400,500,600,700,800,900,1000],["0","100","200","300","400","500","600","700","800","900","1000"]);

a.sub_tics=[9,9,9];

a.box = "back_half";
a.background = -2;
a.tight_limits = ["off","off"];
a.cube_scaling = "on";
a.isoview = "off";
// mit den folgenden einstellungen der drei achsen kann die Anzeige angepasst werden
/////////////////////////////////////////////////////////////////////////////
zh=a.data_bounds;
zh(1,2)=0;
zh(2,2)=1000;
a.data_bounds =zh;
endfunction
///////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// Show2
///////////////////////////////////////////////////////////////////////
mode(0);
// Hier werden Analyse-Daten angezeigt
// Die Daten enthalten die Variablen
// 'afft' 'afftm' 'afftg' 'afftl' 'afftlm' 'afftlg'
// afft > Ergebnisse der FFT
// afftm > Mittelwerte der FFT
// afftg > Ergebnisse der FFT logarythmisch
// afftl > Leitungsspektrum der FFT
// afftlm > Mittelwerte des Leistungsspektrum
// afftlg > Leistungsspektrum logarythmisch
// dat Datei auswählen  
[dateiname,pfad]=uigetfile('*.dat','D:\Mdaten');    //dat Datei wählen
if isequal(dateiname,0);    //Ist eine Date gewählt?
    //
else
    //
    fe=pfad+'\'+dateiname;  //Vollständigen Pfad erstellen
    load(fe);
    /////////////////////////////////////////////
    disp('////////////////////////////////////////////////////////////')
    disp('Scilab-Datei: '+ fe); //Ausgabe vollständiger Pfad
    disp('////////////////////////////////////////////////////////////')
//
//
h1=scf(1);
scf(h1);
// fft
    disp('Zeige Fast Fourier Transformation 3d');
    v=afft(:,1:500);
    v=v*1000;
    t1='Fenster 1';
    t2='FFT';
    px=10;
    py=10;
    cm=100;
    my3dlin(v,t1,t2,px,py,cm);
// fft mittelwert
h2=scf(2);
scf(h2);
    disp('Zeige Fast Fourier Transformation Mittelwerte 2d');
    v=afftm(:,1:500);
    v=v*10000;
    t1='Fenster 2';
    t2='FFT Mittelwerte';
    px=20;
    py=20;
    my2dlin(v,t1,t2,px,py);
//
h3=scf(3);
scf(h3);
    disp('Zeige Leistungsspektrum 3d');
    v=afftl(:,1:500);
    v=v*1000;
    t1='Fenster 3';
    t2='Leistungsspektrum';
    px=30;
    py=30;
    cm=100;
    my3dlin(v,t1,t2,px,py,cm);
//
h4=scf(4);
scf(h4);
    disp('Zeige Leistungsspektrum Mittelwerte 2d');
    v=afftlm(:,1:500);
    v=v*10000;
    t1='Fenster 4';
    t2='Leistungsspektrum Mittelwerte';
    px=40;
    py=40;
    my2dlin(v,t1,t2,px,py);
//    

//




end
//subplot(10,1,1);
//plot(afftlm(1:100));
//gca.grid = [1,1,1];
//gca.x_ticks=tlist(['locations','labels'],[0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100],["0","5","10","15","20","25","30","35","40","45","50","55","60","65","70","75","80","85","90","95","100"]);
//gca.sub_tics=[4,9];
//gca.x_location='top';
 
Private Nachricht senden Benutzer-Profile anzeigen
 
brummfritz
Forum-Anfänger

Forum-Anfänger


Beiträge: 20
Anmeldedatum: 01.09.16
Wohnort: Düsseldorf
Version: Matlab R2015b
     Beitrag Verfasst am: 16.06.2017, 07:24     Titel:
  Antworten mit Zitat      
Auf die Schnelle passieren immer schnell Fehler.

Bei den letzten beiden Skripts werden gespeicherte Scilab Daten eingelesen und angezeigt. Diese Vorgehensweise hat den Vorteile, alle zu analysierenden WAV Dateien werden mit dem folgenden Programm berechnet. Dabei werden alle möglichen Rechnungen durchgeführt. Anschließend werden die Rechenergebnisse im gleichen Ordner, da wo die zu analysierende Datei ist, die Scilab Daten gespeichert.
Das hat den Vorteil, cilab kann viel größere Wav Dateien berechnen da keine Grafik erzeugt werden muß. Erst nach den Rechnungen werden die berechneten Daten Angezeigt.

Also hier das Rechenprogramm.
Im vorigen Beitrag die beiden Programme mit denen die Scilab Daten zur Anzeige gebracht werden.

Code:
// Analyse 2
mode(0);
// Hier werden WAV Dateien analysiert
// Die Abtastrate muss 48000 sein
// Es wird nur 1 Kanal analysiert
// Überdeckung der Analyse 87,5 //
// Die Ergebnisse der berechneten Analyse werden als Scilab Variable gespeichert.
// Die Variablen werden im gleichen Ordner wie die WAV Datei gespeichert.
// Die Variablen:
// afft ist die FFT
// afftm ist die FFT Mittelwerte
// afftg ist die FFT logarhythmisch
// afftmg ist die FFT logarhythmisch Mittelwerte
// afftl ist das leistungsspektrum
// afftlm ist das Leistungsspektrum Mittelwerte
// afftlg ist das Leistungsspektrum logarhythmisch
//afftlgm ist das Leistungsspektrum logharythmisch Mittelwerte
//
//////////////////////////////////////////////////////////////////////////////
mclose('all');
clear;
xdel();
// WAV Datei auswählen  
[dateiname,pfad]=uigetfile('*.wav','D:\Mdaten');    //WAV Datei wählen
if isequal(dateiname,0);    //Ist eine Date gewählt?
    //
else
    //
    fe=pfad+'\'+dateiname;  //Vollständigen Pfad erstellen
    info = wavread(fe,'info');  //WAV Info`s laden
    fd=fileinfo(fe);            //Datei Info`s laden
    disp('////////////////////////////////////////////////////////////')
    disp('WAV-Datei: '+fe); //Ausgabe vollständiger Pfad
    p='Kanäle: '+string(info(2));   //Ausgabe Anzahl der Kanäle
    disp(p);                        //Ausgabe Anzahl der Kanäle
    p='Samplerate: '+string(info(3));   //Ausgabe Samplerate
    disp(p);                            //Ausgabe Samplerate
    p='Dateilänge : '+string(fd(1));    //Ausgabe Dateilänge
    disp(p);                            //Ausgabe Dateilänge
    p='Laufzeit : '+string(info(8)/info(3));    //Laufzeit in Sek.
    disp(p);                                            //Laufzeit in Sek.
        disp('////////////////////////////////////////////////////////////')
    if info(3)==48000 then  //Stimmt die Samplerate der Audiodatei?
        samplmax=info(8);   //Dateilänge als Obergrenze erfassen
        /////////////////////////////////////////////
        start1=1;       //Erstes Byte des Rechenzyklus
        start2=48000;   //Letztes Byte des Rechenzyklus************************
        ueberdeckung=6000;//Überdeckungsabstand
        //===============================================================
        kanal=1;    //Nummer des Kanals der analysiert wird.
        frequ1=1;   //Die FFT wird von dieser Frequenz an berechnet**********
        frequ2=500; //Die FFT wird bis zu dieser Frequenz berechnet************
        //===============================================================
        //
//        aa=loadwave(fe);
        //
        w=0;    //Zähler für das Ergebnis Array
        yW=window('hn',start2); // fenster fsetlegen
        while start2<samplmax   //Prüfe ob Ende der Audiodaten erreicht
            //
            w=w+1;  //Zähler für das Ergebnis Array
            yF=wavread(fe,[start1 start2]); // Audio einlesen für Rechnzyklus
            // window funktion berechenen hanning
            yFW=yW.*yF(1,:); // Window anwenden
            yFFT=fft(yF,-1,'nonsymmetric'); //Die FFT wird berechnen
            yFFT=yFFT/48000;
            g(w)=yFFT(1);
            yFFT=yFFT(2:24001);
            yFFT1=yFFT; // Nur der Realteil der FFT
            yFFT1=abs(yFFT1); // nur positive Zahlen
            yFFT1=yFFT1*2; // amplitude normieren
            afft(w,:)=yFFT1(frequ1:frequ2);  //Ergebnisse ins Array
            // powerspektrum
            yFFTL=yFFT.* conj(yFFT);   //Powerspektrum der FFT berechnen
            yFFTL=abs(yFFTL); // realteil
            yFFTL=yFFTL.*4; // amplitude normieren
            afftl(w,:)=yFFTL(frequ1:frequ2);  //Ergebnisse ins Array
            //
            start1=start1 + ueberdeckung;   //Der Startpunkt für den nächsten Zyklus
            start2=start2 + ueberdeckung;   //Der Endpunkt für den nächsten Zyklus
            //
        end
    else  
    end
//////////////////////////////////////////////////////////////////////////
// mittelwerte bilden
afftm=mean(afft,'r'); //Mittelwert der fft berechnen
//
afftlm=mean(afftl,'r'); //Mittelwert der fftl berechnen
////////////////////////////////////////////
/////////////////////////////////////////////
// log berechnen
////////////////////////////////////////////
afftg=log10(afft);
afftg=afftg.*20; // die fft
///
afftlg=log10(afftl);
afftlg=afftlg.*10; // das leistungsspektrum
//////////////////////////////////////////////////////////////////////////
// mittelwerte log bilden
afftgm=mean(afftg,'r'); //Mittelwert der fft berechnen
//
afftlgm=mean(afftlg,'r'); //Mittelwert der fftl berechnen
//
// werte speichern berechnete daten werden gespeichert
zo=strsplit(dateiname,'.');
zo=pfad+'/'+zo(1)+'_FFT.dat';
save(zo,'afft','afftm','afftg','afftgm','afftl','afftlm','afftlg','afftlgm');
end

mclose('all')
disp('F E R T I G')
Private Nachricht senden Benutzer-Profile anzeigen
 
Neues Thema eröffnen Neue Antwort erstellen



Einstellungen und Berechtigungen
Beiträge der letzten Zeit anzeigen:

Du kannst Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.
Du kannst Dateien in diesem Forum posten
Du kannst Dateien in diesem Forum herunterladen
.


goMatlab ist ein Teil des goForen-Labels
goForen.de goMATLAB.de goLaTeX.de goPCB.de


 Impressum  | Nutzungsbedingungen  | Datenschutz  | Werbung/Mediadaten | Studentenversion | FAQ | goMatlab RSS Button RSS


Copyright © 2007 - 2017 goMatlab.de | Dies ist keine offizielle Website der Firma The Mathworks
Partner: LabVIEWforum.de

MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.