I have a for loop which opens different ascii-files, does some calculations on them and the plots one column against another one from each file, and it does this for the files with numbers ifile to nfile. So I get 1 figure with various plots. Now I want to add a legend with the plotted lines, which just showes the numbers of the files.
This is part of my code:
-------------------------------------------------
infile='ascii';
ifile=1;
nfile=4;
k=1;
for icount=ifile:nfile,
mx(k)=num2str(ifile);
mx_2=mx'
k=k+1;
***here are some calculations and defenition of x_value and y_value***
hold all
plot(x_value,y_value)
ifile=ifile+1;
legend(mx_2);
hold off
end
-------------------------------------------------
So I want to use the vector mx_2 as the legend. If nfile is 4, then I plot 4 lines in one figure, and mx_2 is a vertical vector of 4 strings. However, I do get the following error. WHAT AM I DOING WRONG???
??? Error using ==> strcmp
The number of rows of the string matrix must
match the number of elements in the cell.
Error in ==> legend at 153
elseif (narg==1 && ischar(varargin{1}) && ...
This is part of my code:
-------------------------------------------------
infile='ascii';
ifile=1;
nfile=4;
k=1;
for icount=ifile:nfile,
mx(k)=num2str(ifile);
mx_2=mx'
k=k+1;
***here are some calculations and defenition of x_value and y_value***
hold all
plot(x_value,y_value)
ifile=ifile+1;
legend(mx_2);
hold off
end
-------------------------------------------------
So I want to use the vector mx_2 as the legend. If nfile is 4, then I plot 4 lines in one figure, and mx_2 is a vertical vector of 4 strings. However, I do get the following error. WHAT AM I DOING WRONG???
??? Error using ==> strcmp
The number of rows of the string matrix must
match the number of elements in the cell.
Error in ==> legend at 153
elseif (narg==1 && ischar(varargin{1}) && ...