I keep getting "Array indices must be positive integers or logical values". error
Mostrar comentarios más antiguos
Heres my code, why do I get the error?
clc
clear
% Given values
L = 0.05;
qL = -100-(4.6611*5);
qR = -300+(0.3869*5);
x = linspace(0,0.05,5);
%% Requirement 4
V = zeros(length(x),1);
Vx1(0:(L/2)-1)=1;
Vx2((L/2):L) = (((qR-qL)*x.^2)/L)+((2*qL-qR)*x)-((L/4)*(qL+qR));
Respuesta aceptada
Más respuestas (1)
Steven Lord
el 22 de Oct. de 2022
0 votos
There is no element 0 in an array in MATLAB. The first element is element number 1. You will need to change the line of code that creates the variable Vx1.
You also cannot reference or assign to an element at a fractional index. There is no element 0.05 or 0.025 in MATLAB. Therefore you will also need to change the line that creates the variable Vx2.
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
