Clear Filters
Clear Filters

Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.

3 views (last 30 days)
I'm run this script. Could someone help me
rvar_selec=find(sum(Rsel_matrix)>=(ncut)); if (length(rvar_selec)==0) rvar_selec=find(sum(Rsel_matrix)>(0.25*nstab)); end
if (length(rvar_selec)==0) rvar_selec=rset; end
TrDat_rselec=TrDat(:,rvar_selec);
TeDat_rselec=TeDat(:,rvar_selec);
Model3 = fitcecoc(TrDat_rselec,TrLab_perm)
PredLab2(:,perm)=predict(Model2,TeDat_r) %* (Here, it indicates the error: Unable to perform assignment because the indices on the left side are not compatible with the size of the right side)
PredLab3(:,perm)=predict(Model3,TeDat_rselec

Answers (1)

Walter Roberson
Walter Roberson on 22 Apr 2024
The output of predict(Model2,TeDat_r) will be a vector with the same number of rows as TeDat_r has. But TeDat_r is undefined here -- you probably want to predict(Model2,TeDat_rselec)
You would have a problem if perm is non-scalar.
You would have a problem on the second iteration of this code, if TeDat_rselec changes size then the number of rows output would change.

Community Treasure Hunt

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

Start Hunting!