How to plot a graph with two different length vectors

조회 수: 7 (최근 30일)
Ishara Nipuni
Ishara Nipuni 2018년 11월 25일
댓글: madhan ravi 2018년 11월 25일
Hi,
I need to plot a graph using two datasets which have two different length values. I tried to get the graph with the use of the code I have shown below. But I got an error message as I have shown below the code.
Please someone help me. Thank you !
Entropy_Value =[7.61572,7.56676,6.25456,5.45656,7.32154]; % Y-axis values
Image_Number =[1,2,3,4,5]; % X-axis values
i=0.01:0.001:0.02;
plot(i,Entropy_Value,'b--*',i,Image_Number,'r--o')
%{
Error using plot
Vectors must be the same length.
Error in graph2 (line 4)
plot(i,Entropy_Value,'b--*',i,Image_Number,'r--o')
%}

채택된 답변

madhan ravi
madhan ravi 2018년 11월 25일
편집: madhan ravi 2018년 11월 25일
Use linspace to create points with equal instances
Entropy_Value =[7.61572,7.56676,6.25456,5.45656,7.32154]; % Y-axis values
Image_Number =[1,2,3,4,5]; % X-axis values
i=linspace(0.01,0.02,numel(Entropy_Value));
plot(i,Entropy_Value,'b--*',i,Image_Number,'r--o')
Screen Shot 2018-11-25 at 5.49.26 PM.png
  댓글 수: 4
Ishara Nipuni
Ishara Nipuni 2018년 11월 25일
Thank you so much for the help:-) This code worked correctly for more values :-):-):-):-):-):-)
madhan ravi
madhan ravi 2018년 11월 25일
Anytime :) , make sure to accept and voting the answer if it helped

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by