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

5 visualizaciones (últimos 30 días)
anshu bhatia
anshu bhatia el 10 de Abr. de 2021
Respondida: DGM el 10 de Abr. de 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

Respuestas (1)

DGM
DGM el 10 de Abr. de 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

Categorías

Más información sobre Data Types en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by