How can I plot a serie data using linspace?

Hi everybody
I´m trying to plot 59 data (the variable a and b), but those data corresponds to 90 days, the difference between data and days is because there were days with no measurements.
I´m using this command:
a = E_D/E_C;
b = 1 - a;
x = linspace(0, 90, numel(E_C));
X = [x].';
Y = [b];
err=[E_desv_C(:) E_desv_D(:)];
errorbar(X,Y,err)
xticks(0:5:90);
but appears this error
Error using errorbar>checkSingleInput (line 269)
XData must be the same size as YData.
Error in errorbar (line 94)
x = checkSingleInput(x, sz, 'XData');
Error in Untitled (line 65)
errorbar(X,Y,err)
How can I fix this?
Thank u!

4 件のコメント

KSSV
KSSV 2019 年 7 月 19 日
The dimensions of X and Y should be same....in your case they are not so the error.
Walter Roberson
Walter Roberson 2019 年 7 月 19 日
Do you have information about which 59 days ?
When you get to the days that are not present, do you want a gap in the line? Do you want to draw a straight line over the gap? Do you want interpolation to be done to fill in the space?
Jonathan Bijman
Jonathan Bijman 2019 年 7 月 19 日
The 59 days correspond to the average of measurements (there were 9 measurements per day) and I want to draw a straight line over the gap.
Adam Danz
Adam Danz 2019 年 7 月 20 日
編集済み: Adam Danz 2019 年 7 月 24 日
Do you have a vector of dates that correspond to the 59 data points? For example, do you know what date is associated with point #32?

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

回答 (1 件)

Vinai Datta Thatiparthi
Vinai Datta Thatiparthi 2019 年 7 月 24 日

0 投票

Hi Jonathan!
From your question, I understand that you want to plot the variables ‘a’ and ‘b’ against each other.
Firstly, if you want the output variables ‘a’ & ‘b’ to be vectors, then use the dot operator. The ‘./’ operator returns vectors.
Secondly, the variables ‘E_desv_C(:)’ and ‘E_desv_D(:)’ aren’t defined in your question, I am assuming that they are of the same dimensions as of the variables ‘E_D’ and ‘E_C’. If this is the case, the variable ‘err’ will be of size [59x2]. This is why the error “XData must be the same size as YData” is thrown by MATLAB, since the dimensions of the arrays ‘Y’ and ‘err’ are different. To use errorbar(x,y,err), the variables 'y' & 'err' must be of the same dimensions.

カテゴリ

ヘルプ センター および File ExchangeLine Plots についてさらに検索

タグ

質問済み:

2019 年 7 月 19 日

編集済み:

2019 年 7 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by