how to show difference between two plotted data in graph ?

Hi all:
i plotted two series of data in graph now i want to differentiate between two graphs so i want to know difference of these two graphs in ploting by numerical data .
i mean what difference come between these two graphs it will show me numerically in graph .
d=[120 234 499 324 567 343 550 405 600 700]
m=[123 456 789 456 765 867 989 675 867 433]
figure
plot(d)
hold on
plot(m)
xlabel('solar radition ')
ylabel('haat gain')
legend('heat gain')
title('uuseful heat gain')
thanks in advance

 採用された回答

Mario Malic
Mario Malic 2020 年 10 月 22 日

1 投票

Do you mean difference by this?
c = m-d
plot(c)

6 件のコメント

Engineer Batoor khan mummand
Engineer Batoor khan mummand 2020 年 10 月 22 日
thanks dear from your reply i am very tahnkful .
no i mean i dont want to plot third graph of difference i want to just show difference in numerical data in that plot (which d and m is already plotted)
thanks
Engineer Batoor khan mummand
Engineer Batoor khan mummand 2020 年 10 月 22 日
like this example
Mario Malic
Mario Malic 2020 年 10 月 22 日
c = m-d;
xc = 1:1:length(m);
yc = (m+d)/2;
text(xc,yc,string(c), 'HorizontalAlignment', 'center')
Engineer Batoor khan mummand
Engineer Batoor khan mummand 2020 年 10 月 22 日
編集済み: Image Analyst 2020 年 10 月 22 日
Thanks dear from your reply.
This is my code:
d=[120 234 499 324 567 343 550 405 600 700]
m=[123 456 789 456 765 867 989 675 867 1000]
figure
plot(d)
hold on
plot(m)
c = m-d;
xc = 1:1:length(m);
yc = (m+d)/2;
text(xc,yc,string(c), 'HorizontalAlignment', 'center')
xlabel('solar radition ')
ylabel('haat gain')
legend('heat gain')
title('uuseful heat gain')
It gives me this error:
Error using text
Invalid parameter/value pair arguments
Error in ndfsde (line 10)
text(xc,yc,string(c), 'HorizontalAlignment', 'center')
Mario Malic
Mario Malic 2020 年 10 月 22 日
I do not know how to check documentation for 2017a, so, please check your text function, if 'HorizontalAlignment', 'center' is a valid option and check if string(c) outputs 1x10 string array.
Image Analyst
Image Analyst 2020 年 10 月 22 日
Try this:
d = [120 234 499 324 567 343 550 405 600 700]
m = [123 456 789 456 765 867 989 675 867 1000]
plot(d, '-', 'LineWidth', 2)
hold on
plot(m, '-', 'LineWidth', 2)
grid on;
differences = m - d;
xCenter = 1:1:length(m);
yCenter = (m+d)/2;
for k = 1 : length(xCenter)
textLabel = sprintf('%.1f', differences(k));
text(xCenter(k), yCenter(k), textLabel, 'HorizontalAlignment', 'center')
end
xlabel('Solar Radiation ')
ylabel('Heat gain')
legend('d', 'm', 'Location', 'south')
title('Useful Heat Gain')
Note that the differences are vertical. It doesn't make any sense to have a slanted difference line (between two different time points) like you had.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGraph and Network Algorithms についてさらに検索

製品

リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by