Error Message: Array indices must be positive integers or logical values.

4 Ansichten (letzte 30 Tage)
anshu bhatia
anshu bhatia am 10 Apr. 2021
Beantwortet: DGM am 10 Apr. 2021
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

Antworten (1)

DGM
DGM am 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

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by