How to change my y-plot?

Dear all,
i have my y-plot in the number of steps what matlab computed. But I want it in seconds how do I plot it?
I mean matlab showing from 0 to 4*10^5 in my y-axis but I want to plot in 0 to 14,000 seconds in my y-axis?
I did it manually like assigning a tickmark and setting the time values but it doesn't work out when I zoomed just like half of my data... I have the values of seconds computed in a text file is that anyway possible to implement that seconds into the graph what I have ?

回答 (1 件)

Jan
Jan 2011 年 3 月 17 日

1 投票

Matlab assumes the x-axis values 1 to 4e5 (not 0 to 4e5) automatically:
y = rand(1, 4e5);
figure;
plot(y);
But you can specify the x-axis values easily:
figure;
plot(linspace(0, 14000, numel(y)), y);
No need to define tickmarks manually and no problems at zooming.
If you have problems with plotting, "help plot" and "doc plot" will be very helpful.

3 件のコメント

Fire
Fire 2011 年 3 月 17 日
But I have one more problem like in my final image, i have like different depth at different points which I have to be plot in y according to the depth.
Is that anyway possible, tat I can call the values from excel file to be plotted on y-axis??
Jan
Jan 2011 年 3 月 17 日
Of course you can import the x-axis values from an Excel sheet also instead of using LINSPACE.
I do not understand the question about the "depth". Please post a small example.
Jan
Jan 2011 年 3 月 18 日
@Elavarasan: Are you satisfied by the answer or do you have further question? Can you explain the "depth" related question again?

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

カテゴリ

タグ

質問済み:

2011 年 3 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by