How do I keep the x-axis the same?

3 ビュー (過去 30 日間)
Ethan Koproski
Ethan Koproski 2018 年 3 月 2 日
回答済み: Abraham Boayue 2018 年 3 月 3 日
How can I keep the x-axis the same. I had it from 0-1.8. I found three average points I wanted to plot but when I used the same time it was not the same vector length. I used:
time3 = (0:1/Fs:(length(AvgPoints)-1)*1/Fs);
to get a vector of the same length but it changed it to 0-0.02. Any way I can keep the original x-axis? Here is also the first time command:
time2 = data2.data(:,1)*1/Fs;
<<
>>

回答 (2 件)

Star Strider
Star Strider 2018 年 3 月 2 日
One way:
set(gca, 'XLim',[0 1.8])
Put that set call after the plot call.
  3 件のコメント
Ethan Koproski
Ethan Koproski 2018 年 3 月 2 日
The original graph
Star Strider
Star Strider 2018 年 3 月 2 日
My set call allowed you to keep the original x-axis range.
This is what you wanted, and it worked.
I have no idea what the rest of your code is doing, since you haven’t posted it.

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


Abraham Boayue
Abraham Boayue 2018 年 3 月 3 日
Make sure that your three time vectors have the same length. If you have a time interval between a and b and want the time to have a length N, you can define it like this: t = a: (b-a)/(N-1):b;. Define t1 t2 and t3 in this way. The set(gca, ‘xlim’,[0 1.8]) will not calculate values for this interval, it will only set the axis for that, that’s why you got the narrow graph.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by