Error Message: Array indices must be positive integers or logical values.
5 次查看(过去 30 天)
显示 更早的评论
clear all; clc;
P = 6 * 10^6; %point load at end of the beam
n = 4; % number of elements
l = 3; % length of the bar
E = 100 * 10^9; %Youngs modulus
I = 7.957 * 10^-8; %Moment of Inertia
le = l/n; %length of each element
Force = [-6*10^6 ; 0];
F = zeros(2*n+2);
F(2*n:1+2*n) =+ Force(0);
for i = 1:length(F)
disp(F(i))
end
0 个评论
回答(1 个)
DGM
2021-4-10
I'm not really sure what you're trying to do with the calculations, but this line:
F(2*n:1+2*n) =+ Force(0);
is going to result in an error, since zero is not a positive integer. Matlab uses 1-based indexing convention, so there is no zeroth index in an array. I'm assuming you meant
F(2*n:1+2*n) =+ Force(1);
since that's the only nonzero element of the array
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!