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

回答(1 个)

DGM
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

类别

Help CenterFile Exchange 中查找有关 Data Types 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by