필터 지우기
필터 지우기

How can I resolve this problem?

조회 수: 1 (최근 30일)
Deepesh Kumar Gupta
Deepesh Kumar Gupta 2022년 4월 4일
댓글: Deepesh Kumar Gupta 2022년 4월 4일
why am i getting this error?
Index exceeds the number of array elements. Index must not exceed 30.
Error in Inver_theta_ecc (line 23)
maxvalex= ex(idex);
Here is the code that have written-
clc;
clear all;
r=.011;
q=12;
sigma=5;
FD = csvread("forwardtemp.csv");
ID = csvread("Theta_ecc.csv");
pi=3.1415926;
for i=1:1080
for k=1:68
I(k,i)=(FD(k,1)-ID(k,i)).^2;
end
I;
M=sum(I);
Ppost(i)=exp(-M(i)/(2*q^2))/(2*pi*q^2)^6;
end
Ppostmax= max(Ppost);
O= (Ppost./Ppostmax);
ex=-.009:.001:.02;
[maxvalPpost,idex]=max(Ppost);
maxvalex= ex(idex);
theta=0:10:350;
[maxvalPpost,idtheta]=max(Ppost);
maxvaltheta= theta(idtheta);
sum0=0;
for m=1:30
u(m)= ex(m);
sum1=sum0+u(m);
end
Meanex= sum1/30;
errorMAP_ex= 100*(.017-maxvalex)/(.017)
errorMean_ex=100*(.017-Meanex)/(.017)
for m=1:36
u(m)= theta(m);
sum2=sum0+u(m);
end
Meantheta= sum2/36;
errorMAPtheta= 100*(180-maxvaltheta)/(180)
errorMeantheta=100*(180-Meantheta)/(180)
test=csvread('Theta_ecc.csv');
x=test(:,1);
y=test(:,2);
z=test(:,3);
scatter3(x,y,z)
colormap jet
shading interp;

채택된 답변

Torsten
Torsten 2022년 4월 4일
The arrays "Ppost" and "ex" don't have the same number of elements.
This has the effect that "ex" has less elements than the value of the variable "idex".
Output numel(ex) and idex to see what's going wrong.
The same problem might appear for theta(idtheta).
  댓글 수: 1
Deepesh Kumar Gupta
Deepesh Kumar Gupta 2022년 4월 4일
@Torsten , thank you . The problem has been resolved.

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

추가 답변 (0개)

카테고리

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