Error using plot Vectors must be the same length. Error in Untitled3 (line 125)

조회 수: 1 (최근 30일)
Paulino
Paulino 2023년 3월 19일
댓글: Walter Roberson 2024년 11월 11일
I want to plot different graphs on the same axis for a fucntion S=f(z) at differente initial conditions Ti1 Ti2 and Ti3.
Init=[Fi1 Fi2 Fi3 Fi4 Fi5 Ti1
Fi1 Fi2 Fi3 Fi4 Fi5 Ti2
Fi1 Fi2 Fi3 Fi4 Fi5 Ti3];
for i=1:2
x0=Init(i,:);
zspan=[0 L];
[z,x]=ode45(@mbrf,zspan,x0,[],Pt,rhoc,epsilon,Re,Ri,Perm4,Perm5,dHr1,dHr2,Tv,R,ms,dp,Po,Pa,MW1,MW2,MW3,MW4,MW5);
plot(z,S,'r-','MarkerSize', 1,'LineWidth', 1), xlabel('z(m)'), ylabel('S')
hold on
end

답변 (1개)

Harsh
Harsh 2024년 11월 11일
Hi Paulino,
The error you are encountering is because of the difference in size of the “z” and “S” vectors in your code. You can check the size of a vector using the “size” function. Please ensure that both “z” and “S” are the same size.
Refer to the following documentation link for the “size” function - https://www.mathworks.com/help/matlab/ref/double.size.html
I hope this resolves your query. Happy coding!
  댓글 수: 1
Walter Roberson
Walter Roberson 2024년 11월 11일
Note that when you pass a zspan vector of length 2, the size of the output is variable.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by