フィルターのクリア

How to plot the difference of two different time scaled values in the same plot(Single Plot)

1 回表示 (過去 30 日間)
Vicky vicky
Vicky vicky 2012 年 10 月 11 日
Pl. help me out I want to plot plot(t,(x-y),'b') where x and y have different t scale. for x, t=35 (say) and for y, t=55 data points. I have plotted t,x and t,y in a single plot by using hold on and hold off commands, but plot(t,(x-y),'b') is not working with hold on and hold off. Kindly help me
  1 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 10 月 11 日
編集済み: Azzi Abdelmalek 2012 年 10 月 11 日
what do you want to do with a missing x data? complete with zeros? if x and y are not the same length, what x-y means?

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

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 10 月 11 日
編集済み: Azzi Abdelmalek 2012 年 10 月 11 日
what you can dot is interpolate before calculting x-y
example
close
t1=linspace(0,10,35)
x=sin(t1)
t2=linspace(1,10,55)
y=cos(t2)
%for the missing x data
xi=interp1(t1,x,t2)
plot(t1,x)
hold on,plot(t2,y,'g')
hold on,plot(t2,xi-y,'r')

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by