Search code examples
plotfilenamesscilab

Exporting a file with a variable name in Scilab


Here is what im trying:

  1. Plot a set of points
  2. Export the plot
  3. Alter the position of the points
  4. Plot again
  5. Export again
  6. Alter the position again
  7. ...

The Problem is that i can not create variable filenames for the exported Plots, so my Question is:

How could i export the plots with a filename that is dependant on a variable n for example?

xs2png(0,"C:\directionary\scilab\Frame_n.png")

Solution

  • You can do that in a loop:

    for i = 1 : numberOfImages
        // 
        // manipulate data;
        //
        scf(i) // opens a new graphic window
        plot(data);
        xs2png("C:\directionary\scilab\Frame_"+ string(i) +".png");
    end
    

    The scf command selects the current figure. So you do not have to select the figure number in the xs2png command. Numbers get converted to strings by string() and strings can be brought together with +.