Question #6825   Submitted by Answiki on 10/02/2022 at 06:33:49 PM UTC

With Matlab, how to create a legend with a loop?

Answer   Submitted by Answiki on 10/02/2022 at 06:38:08 PM UTC

One can create a MATLAB legend with a loop thanks to the following script:

N = 5;
Legend=cell(N,1);
for i=1:N
    Legend{i} = sprintf('Text %d', i);
end
legend(Legend);

The above code should display something like:

5 events in history
Answer by Answiki on 10/02/2022 at 06:38:08 PM

One can create a MATLAB legend with a loop thanks to the following script:

N = 5;
Legend=cell(N,1);
for i=1:N
    Legend{i} = sprintf('Text %d', i);
end
legend(Legend);

The above code should display something like:

Question by Answiki 10/02/2022 at 06:37:33 PM
In MATLAB, how to use a loop to create a legend?
Answer by Answiki on 10/02/2022 at 06:37:15 PM

One can create a MATLAB legend with a loop thanks to the following script:

N = 5;
Legend=cell(N,1);
for i=1:N
    Legend{i} = sprintf('Text %d', i);
end
legend(Legend);

The above code should display something like:

Answer by Answiki on 10/02/2022 at 06:36:52 PM

One can create a MATLAB legend with a loop with the following code:

N = 5;
Legend=cell(N,1);
for i=1:N
    Legend{i} = sprintf('Text %d', i);
end
legend(Legend);

The above code should display something like:

Question by Answiki 10/02/2022 at 06:33:49 PM
With Matlab, how to create a legend with a loop?
# ID Query URL Count

Icons proudly provided by Friconix.