How can I resolve this problem?
조회 수: 1 (최근 30일)
이전 댓글 표시
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;
댓글 수: 0
채택된 답변
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).
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!