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!