If the values are almost equal to each other,how do i plot the figure to see its curve? (not straight line )

5 views (last 30 days)
If the values are very similar to each other,how should draw them to see their different?
I mean if the window show me
when a = 1, x1 = 1.111*10^-4
when a = 2, x1 = 1.111*10^-4
when a = 3, x1 = 1.111*10^-4
when a = 4, x1 = 1.111*10^-4
However, each x1 are not the same actually when the a is different however,they are too equal to realize they are not the same from the command window ,how do i plot the figure to see its curve? (not straight line )
i mean the window show me x1 are the same,but actually they are not the same,they are just very very very equal to each other,then how do i write there curve?
i don't want to see the straight line,it should be the curve,because x1 are atually not the same with each other x1

Answers (2)

M
M on 2 Oct 2019
I am not sure to understand the question, but the following code answer your question ?
a=[1 2 3 4];
x=[x1 x2 x3 x4]; % your different values of x1
plot(a,x)
  2 Comments
yang-En Hsiao
yang-En Hsiao on 2 Oct 2019
no,i mean the window show me x1 are the same,but actually they are not the same,they are just very very very equal to each other,then how do i write there curve?
i don't want to see the straight line,it should be the curve,because x1 are atually not the same with each other x1
M
M on 2 Oct 2019
Did you try to change the precision of the axis ?
In addition, what is the difference between your x values ?
I did the following test and you can actually see a difference between the values:
a=[1 2 3];
x=[1 1+10*eps 1-10*eps]
plot(a,x)

Sign in to comment.


Adam Danz
Adam Danz on 2 Oct 2019
Depending on the range of your data, it may be difficult to see the differences when, in fact, the differences are miniscule. In addition to plotting the raw data, you could create an additional plot that shows the difference between the lines.
Here's a demo that plots 3 lines that vary by tiny amounts along the y-axis, too small to see. The second subplot shows the difference between the lines at each x-coordinate.
x = 1:.1:5;
y1 = x + rand(size(x))/100000;
y2 = x + rand(size(x))/100000;
y3 = x + rand(size(x))/100000;
figure()
s1 = subplot(2,1,1);
hold on
plot(x,y1,'DisplayName','y1')
plot(x,y2,'DisplayName','y2')
plot(x,y3,'DisplayName','y3')
xlabel('x')
ylabel('y')
title('raw data')
legend()
s2 = subplot(2,1,2);
hold on
plot(x,y1-y2,'DisplayName','y1-y2')
plot(x,y1-y3,'DisplayName','y1-y3')
plot(x,y2-y3,'DisplayName','y2-y3')
xlabel('x')
ylabel('difference in y')
title('difference in y')
legend()
191002 100927-Figure 1.png
% zoom into the raw data to see difference
xlim(s1,[2.99999,3.00001])
ylim(s1,[2.99999,3.00001])
191002 100955-Figure 1.png

Tags

Community Treasure Hunt

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

Start Hunting!