multiple plots on a single graph with legend labelling

조회 수: 20 (최근 30일)
muhammad jawad mirza
muhammad jawad mirza 2017년 10월 26일
편집: Walter Roberson 2017년 10월 29일
Dear friends I am getting multiple plots(as shown in attached fig) with legend labeling for the data as shown in the attachment.There are four data sets as shown in excel/pdf sheet attached where every data set represents one plot.Now i want to draw these plots in matlab.For this purpose when i use the commands then matlab takes the all data sets as a single set.How to import every data set as independent so that i can get 4 independent plots on a single graph???? plz help regards

답변 (2개)

KSSV
KSSV 2017년 10월 26일
data = rand(3,10) ; % some random data
figure
hold on
plot(data(1,:),'^-r')
plot(data(2,:),'V-b')
plot(data(3,:),'s-g')
legend('data1','data2','data3')
  댓글 수: 2
muhammad jawad mirza
muhammad jawad mirza 2017년 10월 26일
Thanks a lot for replying But i still confuse how to group data in four parts from one excel sheet????and what does it mean by "^,V,s"> ???
Walter Roberson
Walter Roberson 2017년 10월 26일
편집: Walter Roberson 2017년 10월 29일
In MATLAB, anywhere that accepts a marker shape specification will understand that the following codes for marker shapes:
  • ^ - triangle with point upwards
  • * - asterisk
  • + - plus sign
  • o - small circle
  • p - pentagon
  • s - square
  • h - hexagon
  • x - cross
  • v - triangle with point downwards
  • < - triangle with point to the left
  • > - triangle with point to the right
  • . - dot

댓글을 달려면 로그인하십시오.


Walter Roberson
Walter Roberson 2017년 10월 26일
If your spreadsheet is like what you show, with a gap between the data sets, then:
  • if I recall correctly, the first output of xlsread() will fill the gap in with nan values, which you can detect and use to split up the data
  • if not, then the third output of xlsread() should have empty cells in those locations, which you could detect and use to split up the data.
  댓글 수: 1
muhammad jawad mirza
muhammad jawad mirza 2017년 10월 26일
Dear sir walter i am not getting your answer plz see my code which all four data sets as one and generate one plot
>> data=xlsread('1'); >> x=data(:,2); >> y=data(:,1); >> semilogy(x,y) if possible then plz correct my code,i am also attaching the output plot of my code

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by