How to plot a graph with two different length vectors

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')
%}

 Accepted Answer

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 Comments

Thank You so much. But I need to plot the entropy values( the values which are in y axis) with the corresponding image number as 1,2,3,4,5. Can you please help me on that?
Thank You so much. But I need to plot the entropy values( the values which are in y axis) with the corresponding image number as 1,2,3,4,5 and I only need to get a one line. Can you please help me on that?
I also tried the code shown below.
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 got the result that shown below after trying above code.
untitled.jpg
But I need to gget the values of X-axis as 1,2,3,4,5. Can you please help me on that? Thank you again.
Thank you so much for the help:-) This code worked correctly for more values :-):-):-):-):-):-)
Anytime :) , make sure to accept and voting the answer if it helped

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!