Setting similar scale for two graphs

20 ビュー (過去 30 日間)
Alexander Quinto
Alexander Quinto 2017 年 11 月 29 日
コメント済み: Alexander Quinto 2017 年 11 月 29 日
Hey,
I am graphing two data sets that represent height, however one of the data sets has more x values than the other therefore making the scale look off when graphing both to compare them. How would I make the scale the same to be able to compare them on the same figure. I will attach pictures below.
figure;plot(h5(1449:end)/1000);
hold on;plot(-z{5}(714:end));

回答 (1 件)

Kaushik Lakshminarasimhan
Kaushik Lakshminarasimhan 2017 年 11 月 29 日
編集済み: Kaushik Lakshminarasimhan 2017 年 11 月 29 日
You need to use plot(x,y) instead of plot(y), where x is the vector of x-values at which you want to plot y. For example:
x1 = 1:100;
y1 = rand(1,length(x1)); % short dataset
x2 = 0.5:0.5:100;
y2 = rand(1,length(x2)); % long dataset
figure; hold on;
plot(x1,y1);
plot(x2,y2);
  1 件のコメント
Alexander Quinto
Alexander Quinto 2017 年 11 月 29 日
x1 = (h5(1449:end)/1000);
y1 = rand(1,length(x1)); % short dataset
x2 = (-z{5}(714:end));
y2 = rand(1,length(x2)); % long dataset
figure; hold on;
plot(x1,y1);
plot(x2,y2);
This is what I did, I'm not sure if this is what you meant, apologies I'm fairly new to Matlab. This is the graph that came out from the code above.

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

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by