I keep getting "Array indices must be positive integers or logical values". error
Ältere Kommentare anzeigen
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));
Akzeptierte Antwort
Weitere Antworten (1)
Steven Lord
am 22 Okt. 2022
0 Stimmen
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.
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
