Building the legend according to user input.
Ältere Kommentare anzeigen
Hey all,
Hope everyone doing good.
I have a small question here.
I need to get the legend according to input.
Below is my code;
n = 50;
[f,T1, X] = Samplemodel_Instat('Measuring_Data.mat');
%X = {[ 2 4 6] ['Node2' 'Node4' 'Node6']};
for plotnumber = 1:n
c = find(X{1,1} == plotnumber,1);
if ~isempty(c)
c = plotnumber;
if n <= 3
plot(f(1:150:end)/3600,T1(c,1:150:end),'Color',[0.831372559070587 0.815686285495758 0.7843137383461]);
% legend(X{1+1}(col,row));
%plot(f(1:200:end)/3600,T1(c,1:200:end),'DisplayName',X{1+1}(col,row));
elseif n > 3
if c >= 1 && c <= ceil(n./4)
plot(f(1:200:end)/3600,T1(c,1:200:end),'Color',[0.25 0.25 0.25],'LineWidth',4,'LineStyle','-.','MarkerFaceColor',[1 1 1],'Marker','none');
% legend(X{1+1}(col,row));
%plot(f(1:200:end)/3600,T1(c,1:200:end),'DisplayName',X{1+1}(col,row));
elseif c > (ceil(n./4)) && c <= ceil(n./2)
plot(f(1:200:end)/3600,T1(c,1:200:end),'Color',[0.952941179275513 0.87058824300766 0.733333349227905],'LineWidth',2,'MarkerFaceColor',[1 1 1],'Marker','s');
% legend(X{1+1}(col,row));
%plot(f(1:200:end)/3600,T1(c,1:200:end),'DisplayName',X{1+1}(col,row));
elseif c > (ceil(n./2)) && c <= ceil(3*n./4)
plot(f(1:200:end)/3600,T1(c,1:200:end),'Color',[0.31 0.31 0.31],'LineWidth',2,'LineStyle','-','Marker','d','MarkerFaceColor',[1 1 1]);
% legend(X{1+1}(col,row));
%plot(f(1:200:end)/3600,T1(c,1:200:end),'DisplayName',X{1+1}(col,row));
elseif c > (ceil(3*n./4)) && c <= n
plot(f(1:150:end)/3600,T1(c,1:150:end),'Color',[0.831372559070587 0.815686285495758 0.7843137383461]);
% legend(X{1+1}(col,row));
%plot(f(1:200:end)/3600,T1(c,1:200:end),'DisplayName',X{1+1}(col,row));
end
end
end
end
Here I need to get the legend everytime for the respective c.
For an example if c = 2, legend should be Oil. You can see how c become 2 in X above.
I hope that it is eary to understand.
Any suggestions and answered are most welcomed.
Thanks in advance
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Legend finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!