MATLAB graph plotting: assigning legend labels during plot

前端 未结 5 779
傲寒
傲寒 2020-12-29 12:11

I am plotting data in a typical MATLAB scatterplot format. Ordinarily when plotting multiple datasets, I would use the command \'hold on;\', and then plot each of the data,

5条回答
  •  悲&欢浪女
    2020-12-29 12:29

    Make a for loop. But Before the for loop, make an array.

    %for example 
    
    legendset = {}
    
    for i = 1:10 
    
    %blabla
    %Then in the fore loop say: 
    
    legendset = [legendset;namedata(i)]
    
    %It puts all names in a column of legendset. 
    %Make sure namedata are characters. 
    
    %foreloop ends
    end
    
    %Then after the foreloop say: 
    
    legend(legendset). 
    

提交回复
热议问题