Error using plot, vectors must be same length

조회 수: 3 (최근 30일)
Saad Khan
Saad Khan 2019년 12월 9일
답변: Saad Khan 2019년 12월 9일
Dear MATLAB experts,
sorry for the dumb question but im in serious need of help.
Im doing alot of different calculations and some of the results that i will be using is placed in two vectors, c and H.
the size for them is: c: 64x4double and H:69x1double.
Im trying to do a plot of H and c where H is the x-axis and c being y-axis.
I have tried changing the code but it messes up my calculations.
If anyone knows a solution to avoid this it would be much appreciated.
I attached the code in the file: optim_o2_co_vs_height.m
p.s im still learning how to use MATLAB
Best Regards
Saad Khan

채택된 답변

Saad Khan
Saad Khan 2019년 12월 9일
Hi,
that's what im looking for, some way to force it to plot identical size of the "c".
Is it possible to crop H?
its a concentration vs height plot and a concentration vs temperature that im trying to do.
Best Regards
Saad Khan
  댓글 수: 1
Nicolas B.
Nicolas B. 2019년 12월 9일
Could you please convert your answer post into a comment post?
To crop H, you need to decide which samples of H are not relevant to plot data. E.g:
H(5:end)
or
H(1:end-5)

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Nicolas B.
Nicolas B. 2019년 12월 9일
편집: Nicolas B. 2019년 12월 9일
I have a question of logic about what you want to plot. Because you want t plot with:
  • x-axis: H, size 69x1
  • y-axis: c(:, 1), size 64x1
So there are 5 missing samples in the y-axis!
You should define whether you want to crop your H-vector while plotting or if you need to add some values to c in order to plot.
Edit: you will have the same problem at line 166 where Temperature's size is also 69x1.

Saad Khan
Saad Khan 2019년 12월 9일
I just tried to change the ODE solver and I get different sizes of the different vectors. I assume its because of the limits each ODE has.
For the H, i just want values until 3 is reached or 3+ 0.09.
Should i just implement it in the plot commando e.g:
plot(H(1:end-5),c(1:etc....)?
Best Regards

카테고리

Help CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by