How can I resolve this problem?

4 visualizzazioni (ultimi 30 giorni)
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;

Risposta accettata

Torsten
Torsten il 4 Apr 2022
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).

Più risposte (0)

Categorie

Scopri di più su Matrices and Arrays in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by