showing error " Array indices must be positive or logical values"

조회 수: 25 (최근 30일)
Prasannakumar reddy
Prasannakumar reddy 2024년 4월 4일 14:11
이동: VBBV 2024년 4월 5일 5:16
clc
clear all
N=2;
c=linspace(0.035,0.010,21)
r=linspace(0.0001,1,21)
thetaroot=15;
thetatip=4;
a=5.7
R=0.35;
theta=(thetaroot+(r.*(thetatip-thetaroot)))./57.3
sigma=(N.*c(i))./(pi.*R)
lambda=sigma.*a((sqrt(1+32.*theta.*r)./(sigma(i).*a))-1)
  댓글 수: 1
VBBV
VBBV 2024년 4월 4일 15:10
이동: VBBV 2024년 4월 5일 5:16
i & j are complex quantities in Matlab, if you use it as index without assigning any value to them would give such error, since Matlab uses 1 based positive integer indexing
clc
clear all
N=2;
c=linspace(0.035,0.010,21);
r=linspace(0.0001,1,21);
thetaroot=15;
thetatip=4;
a=5.7;
R=0.35;
theta=(thetaroot+(r.*(thetatip-thetaroot)))./57.3;
sigma=(N.*c)./(pi.*R) % i & j are complex quantities in Matlab
sigma = 1x21
0.0637 0.0614 0.0591 0.0568 0.0546 0.0523 0.0500 0.0477 0.0455 0.0432 0.0409 0.0387 0.0364 0.0341 0.0318 0.0296 0.0273 0.0250 0.0227 0.0205 0.0182
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
lambda=sigma.*a((sqrt(1+32.*theta.*r)./(sigma.*a))-1) % same in this line
Array indices must be positive integers or logical values.

댓글을 달려면 로그인하십시오.

답변 (2개)

Torsten
Torsten 2024년 4월 4일 14:13
편집: Torsten 2024년 4월 4일 14:15
lambda=sigma.*a.*((sqrt(1+32.*theta.*r)./(sigma(i).*a))-1)
instead of
lambda=sigma.*a((sqrt(1+32.*theta.*r)./(sigma(i).*a))-1)
And since "i" is undefined, c(i) and thus sigma(i) are empty.
  댓글 수: 2
Image Analyst
Image Analyst 2024년 4월 4일 14:27
If this Answer solves your original question, then could you please click the "Accept this answer" link to award the answerer with "reputation points" for their efforts in helping you? They'd appreciate it. Thanks in advance. 🙂 Note: you can only accept one answer (so pick the best one) but you can click the "Vote" icon for as many Answers as you want. Voting for an answer will also award reputation points.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2024년 4월 4일 14:27
이동: VBBV 2024년 4월 5일 5:16
See the FAQ for a thorough discussion of the error:

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by