Gast
#2440469
Hoffe bin hier richtig.
Also ich programmiere nun seit 4 Stunden das erste mal ein Matlab script
und Matlab im allgemienen.
Ich habe hüppelweise Messwerte mit einem LMG aufgenommen und baue nun
ein Script das mir möglichst einfach die Werte aus einer Excel Datei
ausliest, bearbeitet und wieder reinschriebt. Wollte auch erst noch das
es direkt auch Graphen macht aber das funktioniert nicht richtig und
habs dann sein gelassen.
Nun 2 Fragen.
1: Ich habe eine 500x2 Matrix in Matlab 1. Spalte Frequenz 2.Spalte
Impedanz
Da ich nun aber nicht alle Frequenzen in meinem Diagramm haben möchte,
würde ich gerne die Matrix Filtern. Also z.B. die 10 Größten
Impedanzwerte mit passender Frequenz.
Wie sähe dazu der Code aus ich finde bzw verstehe die Syntax noch nicht
so ganz zu dieser max() funktion.
2: Kann man in Excel einen ablauf "vorklicken" das daraus ein Script
erstellt wird, was mir die Graphen macht (Werte liegen immer an der
gleichen Stelle). Oder weiß jemand wie es in Matlab richtig geht? (EXCEL
2007) also xlsgraph() geht nicht... :(
Und das würde mir die arbeit verleichtern wie kann ich z.b: eine .csv
Datei benutzen und dann als Excel Datei wieder speichern?
Achja mein Code bisher:
[fileName filePath] = uigetfile('*', 'Select data file', '.');
if filePath==0, error('None selected!'); end
File =[filePath fileName];
sheet= fileName(1:end-5);
FREQ=xlsread(File,sheet,'A6:A505');
IL1=xlsread(File,sheet,'B6:B505');
IL1PHI=xlsread(File,sheet,'H6:H505');
IL1PHIRAD=IL1PHI*(pi/180);
IL1KOMP=(IL1.*cos(IL1PHIRAD))+(IL1.*sin(IL1PHIRAD))*1i;
IL2=xlsread(File,sheet,'B6:B505');
IL2PHI=xlsread(File,sheet,'H6:H505');
IL2PHIRAD=IL2PHI*(pi/180);
IL2KOMP=(IL2.*cos(IL2PHIRAD))+(IL2.*sin(IL2PHIRAD))*1i;
IL3=xlsread(File,sheet,'B6:B505');
IL3PHI=xlsread(File,sheet,'H6:H505');
IL3PHIRAD=IL3PHI*(pi/180);
IL3KOMP=(IL3.*cos(IL3PHIRAD))+(IL3.*sin(IL3PHIRAD))*1i;
IU=xlsread(File,sheet,'B6:B505');
IUPHI=xlsread(File,sheet,'H6:H505');
IUPHIRAD=IUPHI*(pi/180);
IUKOMP=(IU.*cos(IUPHIRAD))+(IU.*sin(IUPHIRAD))*1i;
IV=xlsread(File,sheet,'B6:B505');
IVPHI=xlsread(File,sheet,'H6:H505');
IVPHIRAD=IVPHI*(pi/180);
IVKOMP=(IV.*cos(IVPHIRAD))+(IV.*sin(IVPHIRAD))*1i;
IW=xlsread(File,sheet,'B6:B505');
IWPHI=xlsread(File,sheet,'H6:H505');
IWPHIRAD=IWPHI*(pi/180);
IWKOMP=(IW.*cos(IWPHIRAD))+(IW.*sin(IWPHIRAD))*1i;
UL1=xlsread(File,sheet,'N6:N505');
UL1PHI=xlsread(File,sheet,'T6:T505');
UL1PHIRAD=UL1PHI*(pi/180);
UL1KOMP=UL1.*cos(UL1PHIRAD)+(UL1.*sin(UL1PHIRAD))*1i;
UL2=xlsread(File,sheet,'N6:N505');
UL2PHI=xlsread(File,sheet,'T6:T505');
UL2PHIRAD=UL2PHI*(pi/180);
UL2KOMP=UL2.*cos(UL2PHIRAD)+(UL2.*sin(UL2PHIRAD))*1i;
UL3=xlsread(File,sheet,'N6:N505');
UL3PHI=xlsread(File,sheet,'T6:T505');
UL3PHIRAD=UL3PHI*(pi/180);
UL3KOMP=UL3.*cos(UL3PHIRAD)+(UL3.*sin(UL3PHIRAD))*1i;
UU=xlsread(File,sheet,'N6:N505');
UUPHI=xlsread(File,sheet,'T6:T505');
UUPHIRAD=UUPHI*(pi/180);
UUKOMP=UU.*cos(UUPHIRAD)+(UU.*sin(UUPHIRAD))*1i;
UV=xlsread(File,sheet,'N6:N505');
UVPHI=xlsread(File,sheet,'T6:T505');
UVPHIRAD=UVPHI*(pi/180);
UVKOMP=UV.*cos(UVPHIRAD)+(UV.*sin(UVPHIRAD))*1i;
UW=xlsread(File,sheet,'N6:N505');
UWPHI=xlsread(File,sheet,'T6:T505');
UWPHIRAD=UWPHI*(pi/180);
UWKOMP=UW.*cos(UWPHIRAD)+(UW.*sin(UWPHIRAD))*1i;
ZL1KOMP=UL1KOMP./IL1KOMP;
ZL1BET=abs(ZL1KOMP);
ZL1VERS=angle(ZL1KOMP);
ZL1KOMPREAL=real(ZL1KOMP);
ZL1KOMPIM=imag(ZL1KOMP);
ZL2KOMP=UL2KOMP./IL2KOMP;
ZL2BET=abs(ZL2KOMP);
ZL2VERS=angle(ZL2KOMP);
ZL2KOMPREAL=real(ZL2KOMP);
ZL2KOMPIM=imag(ZL2KOMP);
ZL3KOMP=UL3KOMP./IL3KOMP;
ZL3BET=abs(ZL3KOMP);
ZL3VERS=angle(ZL3KOMP);
ZL3KOMPREAL=real(ZL3KOMP);
ZL3KOMPIM=imag(ZL3KOMP);
ZUKOMP=UUKOMP./IUKOMP;
ZUBET=abs(ZUKOMP);
ZUVERS=angle(ZUKOMP);
ZUKOMPREAL=real(ZUKOMP);
ZUKOMPIM=imag(ZUKOMP);
ZVKOMP=UVKOMP./IVKOMP;
ZVBET=abs(ZVKOMP);
ZVVERS=angle(ZVKOMP);
ZVKOMPREAL=real(ZVKOMP);
ZVKOMPIM=imag(ZVKOMP);
ZWKOMP=UWKOMP./IWKOMP;
ZWBET=abs(ZWKOMP);
ZWVERS=angle(ZWKOMP);
ZWKOMPREAL=real(ZWKOMP);
ZWKOMPIM=imag(ZWKOMP);
ZKOMALL=[FREQ ZL1KOMP];
%ZKOMBIG=
xlswrite(File,{'Frequenz'} ,'matlab','A1');
xlswrite(File,FREQ ,'matlab','A2');
xlswrite(File,{'ZL1 Komplex'} ,'matlab','B1');
xlswrite(File,{'ZL1 Realteil'} ,'matlab','C1');
xlswrite(File,{'ZL1 Imaginärteil'} ,'matlab','D1');
xlswrite(File,ZL1KOMP ,'matlab','B2');
xlswrite(File,ZL1KOMPREAL ,'matlab','C2');
xlswrite(File,ZL1KOMPIM ,'matlab','D2');
xlswrite(File,{'ZL2 Komplex'} ,'matlab','E1');
xlswrite(File,{'ZL2 Realteil'} ,'matlab','F1');
xlswrite(File,{'ZL2 Imaginärteil'} ,'matlab','G1');
xlswrite(File,ZL2KOMP ,'matlab','E2');
xlswrite(File,ZL2KOMPREAL ,'matlab','F2');
xlswrite(File,ZL2KOMPIM ,'matlab','G2');
xlswrite(File,{'ZL3 Komplex'} ,'matlab','H1');
xlswrite(File,{'ZL3 Realteil'} ,'matlab','I1');
xlswrite(File,{'ZL3 Imaginärteil'} ,'matlab','J1');
xlswrite(File,ZL3KOMP ,'matlab','H2');
xlswrite(File,ZL3KOMPREAL ,'matlab','I2');
xlswrite(File,ZL3KOMPIM ,'matlab','J2');
xlswrite(File,{'ZU Komplex'} ,'matlab','K1');
xlswrite(File,{'ZU Realteil'} ,'matlab','L1');
xlswrite(File,{'ZU Imaginärteil'} ,'matlab','M1');
xlswrite(File,ZUKOMP ,'matlab','K2');
xlswrite(File,ZUKOMPREAL ,'matlab','L2');
xlswrite(File,ZUKOMPIM ,'matlab','M2');
xlswrite(File,{'ZV Komplex'} ,'matlab','N1');
xlswrite(File,{'ZV Realteil'} ,'matlab','O1');
xlswrite(File,{'ZV Imaginärteil'} ,'matlab','P1');
xlswrite(File,ZVKOMP ,'matlab','N2');
xlswrite(File,ZVKOMPREAL ,'matlab','O2');
xlswrite(File,ZVKOMPIM ,'matlab','P2');
xlswrite(File,{'ZW Komplex'} ,'matlab','Q1');
xlswrite(File,{'ZW Realteil'} ,'matlab','R1');
xlswrite(File,{'ZW Imaginärteil'} ,'matlab','S1');
xlswrite(File,ZWKOMP ,'matlab','Q2');
xlswrite(File,ZWKOMPREAL ,'matlab','R2');
xlswrite(File,ZWKOMPIM ,'matlab','S2');