Error Message: Array indices must be positive integers or logical values.
4 views (last 30 days)
Show older comments
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 Comments
Answers (1)
DGM
on 10 Apr 2021
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 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices 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!