I have a huge amount of data to plot, and thanks to:
x=matlab.lang.makeValidName(strcat(...));
assignin('base',x,I);
for each loop of process, where I calculate I
, I assign the value of I
(a vector) to the variable name I_Pnum1_Bnum2
where num1
is the value of P and num2
the value of B. So, at the end I have lots of I
's for:
num1=-4:-1:-14;
num2=[0 5 10 20:20:120 150 170 200 220];
That's why, for each value of P, I want to plot (on the same graph) all I
's for different B:
num1=-4:-1:-14;
num2=[0 5 10 20:20:120 150 170 200 220];
for i=1:length(num1)
legend=[];
figure(i)
for j=1:length(num2)
Y=matlab.lang.makeValidName(strcat('I_p',num2str(abs(num1(i))),'_B',num2str(double(num2(j)))));
plot(V,eval(Y),'linewidth',2)
hold on
leg=strcat("B= ",num2str(b(j)));
legend=[legend leg];
end
title(strcat("Caractéristiques I(V) @",num2str(p(i)),"dBm"))
legend(legend);
end
clc;
The problem: I get
Function 'subsindex' is not defined for values of class 'string'.
and it is due to the line legend(legende), and I don't understand why, because the vector legende is well defined.