cant workout why vectors aren't the same length
1 view (last 30 days)
Show older comments
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 Comments
Answers (1)
James Tursa
on 15 May 2019
Edited: James Tursa
on 15 May 2019
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 Comments
See Also
Categories
Find more on Two y-axis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!