help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: eval(sprintf("title('Ar-Beam(TC%iarBeam%i), %i')", nMessreihe, uu, N


From: William Krekeler
Subject: RE: eval(sprintf("title('Ar-Beam(TC%iarBeam%i), %i')", nMessreihe, uu, NameCellstr[rr])) doesn't work, but why ?
Date: Wed, 17 Nov 2010 15:49:35 +0000

It is not clear to me why you are using eval? Many of the commands you are trying can be done without using eval.

 

Example:

 

figure( uu);         % get the desired figure creates if non-existent

xlabel( sprintf( ‘label %d’, rr ) ); % set xlabe to label rr where rr is a number

 

Removing the eval may simplify the code. Also, you may have to map your namecellstr to a character array and use the %s format input to sprintf.

 

You can use figure(number) to assign current figure focus to figure(number) and then gcf will refer to figure(number) for all variables changed.

 

You can use the print command to save plots as images. Not sure what the octave equivalent to Matlab’s hgsave is to save as editable figures. Hope some of that helped.

 

Bill Krekeler

From: Sina Calmote [mailto:address@hidden
Sent: Wednesday, November 17, 2010 9:41 AM
To: address@hidden
Subject: eval(sprintf("title('Ar-Beam(TC%iarBeam%i), %i')", nMessreihe, uu, NameCellstr[rr])) doesn't work, but why ?

 


Hey there

I try to make several plots in a loop. I can generate the plots in the loop, but I can't change the title as I liked nor can I save the plots. Maybe someone has an idea...

CODE:

% Presettings
%--------------------------
nfiles     = 10 ;              % Anzahl Datenfiles in der Messreihe TCi
nMessreihe = 10 ;             % Nummer in der Messreihe z.B. Serie 6 (TC6)
nSequences = 8 ;              % Anzahl Sequences pro Umdrehung (da das Rad 8 Löcher hat, sollte hier immer eine 8 stehen)
Tmeassure  = 202 ;            % Ist-Wert der Temp.anzeige der Nozzleheizung
ncell      = 1 ;

Name = ["R"; "BR";"C"; "BC";"E"; "BE";"S"; "BS"];
NameCellstr = cellstr(Name)

for uu = 1 : nfiles
    for rr = 1 :  nSequences/2
        eval(sprintf("figure"))#(%i)",uu))
      
        #eval(sprintf("title('Ar-Beam(TC%iarBeam%i), %i')",nMessreihe,uu,NameCellstr[rr]))
        eval(sprintf("xlabel('bin')"))
        eval(sprintf("ylabel('counts')"))
        eval(sprintf("axis([2400 2550 0 4000])"))
        #eval(sprintf("legend('NameCellstr(%i)', 'NameCellstr(%i+1)')",rr))
        #eval(sprintf("print('C%ibeam%ip%i.png')"),nMessreihe,uu,rr)
    endfor
endforfor uu = 1 : nfiles
    for rr = 1 :  nSequences/2
        eval(sprintf("figure"))#(%i)",uu))
        eval(sprintf("plot(t,Z%i(:,2*(%i-1)+1),'-*r','markersize',1.2,t,Z%i(:,2*(%i-1)+2),'-*b','markersize',1.2)",uu,rr,uu,rr)) % Wichtig beim eval(sprintf()) ist, dass der "Text" darin fortlaufend ist und nicht durch einen Zeilenunterbruch gestört wird => ergibt syntaxe error
        #eval(sprintf("title('Ar-Beam(TC%iarBeam%i), %i')",nMessreihe,uu,NameCellstr[rr]))
        eval(sprintf("xlabel('bin')"))
        eval(sprintf("ylabel('counts')"))
        eval(sprintf("axis([2400 2550 0 4000])"))
        #eval(sprintf("legend('NameCellstr(%i)', 'NameCellstr(%i+1)')",rr))
        #eval(sprintf("print('C%ibeam%ip%i.png')"),nMessreihe,uu,rr)
    endfor
endfor

ENDCODE

 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]