cant workout why vectors aren't the same length

1 ビュー (過去 30 日間)
Alexander Bradley 2019 年 5 月 15 日

kwr = zeros(length(0:0.001:0.01));
z = 0;
for X = 0:0.001:0.1;
z=z+1;
kwr(z)= ((ksr*((-4)*B*(X.^2) - 0.7*A*X+Rro).^2 - (Sr*dRrdX))./((-4)*B*(X.^2) - 0.7*A*X+Rro));
end
plot(X,kwr)
xlabel('verticle wheel travel (m)')
ylabel('wheel rate (N/m)')
title('verticle Wheel travel against rear wheel rate')
trying to plot this but keeps saying that the vectors are diferent sizes, cant see why

0 件のコメント

サインイン to comment.

回答 (1 件)

James Tursa 2019 年 5 月 15 日

If you pass zeros( ) only one argument, it creates a square 2D matrix, not a vector. So give it two arguments to make your result a row vector:
kwr = zeros(1,length(0:0.001:0.01));
And you should set X
X = 0:0.001:0.1;
That being said, why not just avoid the loop entirely:
X = 0:0.001:0.1;
kwr = ((ksr*((-4)*B*(X.^2) - 0.7*A*X+Rro).^2 - (Sr*dRrdX))./((-4)*B*(X.^2) - 0.7*A*X+Rro));

0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。

R2017a

Translated by