Several graphs in 1 loop, each iteration adds a line on every figure

Trying to engineer the following in Matlab:

** loop start;
   y(:,i) = function of x;
   z(:,i) = function of x;
   plot(x,y(:,i))   on figure 1, hold all;
   plot(x,z(:,i))   on figure 2, hold all;
** loop end;
   add title, legend, etc for figure 1 (NB: we have multiple lines);
   add title, legend, ets for figure 2 (NB: same, have multiple lines for the legend);`

Tried multiple combinations without much luck. Managed to get 2 figures but only the 2-nd displays multiple lines, not the first. And can't figure how to add legends to these 2 correctly.

Answers


Save a handle to each figure, and to each axis object:

fh1 = figure;
hold all;
ah1 = gca;

fh2 = figure;
hold all;
ah2 = gca;

for i=1:N
    y(:,i) = function of x;
    z(:,i) = function of x;
    plot(ah1, x, y(:,i)); %# tell it which axis to use (ah1)
    plot(ah2, x, z(:,i)); %# (ah2)
end

legend(ah1, ...) %# legend options here
legend(ah2, ...) %# and the other legend

%# note: you can set figure properties for each using fh1, fh2 handles.

Need Your Help

Javascript in asp.net MVC… Beginner issue

javascript html asp.net-mvc

I created an Asp.Net MVC Internet Aplication and in my Index view of the Home Controller I have this

Displaying dates in localized format on Android

android localization internationalization android-viewbinder

I'm currently building my first app for Android. What I'm having trouble with is the storage and localized display of dates in connection with a SimpleCursorAdapter. I have a class that encapsulates

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.