Matlab does not plot data which are mirrored data

2 ビュー (過去 30 日間)
I G
I G 2021 年 2 月 27 日
編集済み: Cris LaPierre 2021 年 2 月 27 日
I have variable r with dimension [1x2002] and values
r = [1 0.9 0.8 0.7 . . . 0.7 0.8 0.9 1]
and variable u0 with dimension [1x2002] and values
u0 = [0 0.0001 0.0002 . . . 0.0002 0.0001 0]
When I plot these data as plot(r, u0) I got only half of these values, but I need all values from my variables (whole velocity profile u0, not just half velocity profile as I got), how I can do that?

回答 (2 件)

Cris LaPierre
Cris LaPierre 2021 年 2 月 27 日
編集済み: Cris LaPierre 2021 年 2 月 27 日
It's plotting it all. It just appears that your data overlaps itself.
Compare these examples
r=abs(-1:0.1:1);
u0=-abs(-1:0.1:1) + 1;
plot(r,u0)
% to this
r=-1:0.1:1;
u0=-abs(-1:0.1:1) + 1;
plot(r,u0)
You can check this by plotting without specifying x values. This will plot the y values using their index number as for x. This will allow you to see the values of every u0 value.
plot(u0)
  2 件のコメント
I G
I G 2021 年 2 月 27 日
編集済み: I G 2021 年 2 月 27 日
How can I plot data as on second graph, just this values -1 and -0.5 on x axis needs to be positive? So I need that my x axis has values 1 0.5 0 0.5 1
Cris LaPierre
Cris LaPierre 2021 年 2 月 27 日
編集済み: Cris LaPierre 2021 年 2 月 27 日
That would confuse me, but your xticklabels do not have to be the same as your xtick locations. I might do something like this to put it on the same plot.
r=-1:0.1:1;
u0=-abs(-1:0.1:1) + 1;
plot(r,u0)
xticklabels(abs(str2double(xticklabels)))
To use the approach that uses the index number for x, you could do something like this.
plot(u0)
xlim([1,length(u0)])
xticks(linspace(1,length(u0),5))
xticklabels(abs(linspace(-1,1,5)))

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


Jan
Jan 2021 年 2 月 27 日
If the 2nd half of the data equals the 1st half in different order, you do plot all data, but the line overlap. See:
r = [1 0.9 0.8 0.7 0.7 0.8 0.9 1]
u0 = [0 0.0001 0.0002 0.003 0.003 0.0002 0.0001 0]
figure
plot(r, u0)
figure
plot(r(1:4), u0(1:4), 'r+')
hold on
plot(r(5:8), u0(5:8), 'bo')
  1 件のコメント
I G
I G 2021 年 2 月 27 日
How can I plot it as in mirror, so that they not overlap each other?

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

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by