I keep getting "Array indices must be positive integers or logical values". error
古いコメントを表示
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));
採用された回答
その他の回答 (1 件)
Steven Lord
2022 年 10 月 22 日
0 投票
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.
カテゴリ
ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
