Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Subscripted assignment dimension mismatch error

조회 수: 6 (최근 30일)
Olivia Parczyk
Olivia Parczyk 2018년 7월 13일
마감: MATLAB Answer Bot 2021년 8월 20일
Hello,
I have checked other threads with this error, but I still could not work it out. The error comes up at the end of my script, where I want to gather all variables I have constructed so far into "Table". It looks like this:
Table(vp,:)= [FPRt, FPFM, FPTTP, FP_Freq, Rt_mean,F_mean,TTP_mean,slowfreqRH,slowfreqWH,correctfreq,errorfreq,Stim_Efreq,...
Stim_ErSl, FrqRtng,...
correctFmax, errorFmax, MeanFmaxleft, Rtng_MeanFmaxleft,MeanFmaxleft_Cor, Rtng_MeanFmaxleft_Cor, MeanFmaxleft_Er, Rtng_MeanFmaxleft_Er, MeanFmaxright, Rtng_MeanFmaxright, MeanFmaxright_Cor, Rtng_MeanFmaxright_Cor, MeanFmaxright_Er, Rtng_MeanFmaxright_Er,...
correctRt, errorRt, MeanRtleft, Rtng_MeanRtleft, MeanRtleft_Cor, Rtng_MeanRtleft_Cor, MeanRtleft_Er, Rtng_MeanRtleft_Er, MeanRtright, Rtng_MeanRtright, MeanRtright_Cor, Rtng_MeanRtright_Cor, MeanRtright_Er, Rtng_MeanRtright_Er,...
correctTTP, errorTTP, MeanTTPleft, Rtng_MeanTTPleft, MeanTTPleft_Cor, Rtng_MeanTTPleft_Cor, MeanTTPleft_Er, Rtng_MeanTTPleft_Er, MeanTTPright, Rtng_MeanTTPright, MeanTTPright_Cor, Rtng_MeanTTPright_Cor, MeanTTPright_Er, Rtng_MeanTTPright_Er,...
ErrorDet, MeanRt_ErrorDet, Rtng_MeanRt_ErrorDet, MeanFmax_ErrorDet, Rtng_MeanFmax_ErrorDet, MeanTTP_ErrorDet, Rtng_MeanTTP_ErrorDet, ErrorUndet, MeanRt_ErrorUndet, Rtng_MeanRt_ErrorUndet, MeanFmax_ErrorUndet, Rtng_MeanFmax_ErrorUndet, MeanTTP_ErrorUndet, Rtng_MeanTTP_ErrorUndet,...
FalseAlarm, MeanRt_FalseAlarm, Rtng_MeanRt_FalseAlarm, MeanFmax_FalseAlarm, Rtng_MeanFmax_FalseAlarm, MeanTTP_FalseAlarm, Rtng_MeanTTP_FalseAlarm, CorrectDet, MeanRt_correctDet, Rtng_MeanRt_correctDet, MeanFmax_correctDet, Rtng_MeanFmax_correctDet, MeanTTP_correctDet, Rtng_MeanTTP_correctDet,...
ErrorDetUns, MeanRt_ErrorDetUns, Rtng_MeanRt_ErrorDetUns, MeanFmax_ErrorDetUns, Rtng_MeanFmax_ErrorDetUns, MeanTTP_ErrorDetUns, Rtng_MeanTTP_ErrorDetUns, ErrorUndetUns, MeanRt_ErrorUndetUns, Rtng_MeanRt_ErrorUndetUns, MeanFmax_ErrorUndetUns, Rtng_MeanFmax_ErrorUndetUns, MeanTTP_ErrorUndetUns, Rtng_MeanTTP_ErrorUndetUns,...
FalseAlarmUns, MeanRt_falseAlarmUns, Rtng_MeanRt_falseAlarmUns, MeanFmax_falseAlarmUns, Rtng_MeanFmax_falseAlarmUns, MeanTTP_falseAlarmUns, Rtng_MeanTTP_falseAlarmUns, CorrectDetUns, MeanRt_correctDetUns, Rtng_MeanRt_correctDetUns, MeanFmax_correctDetUns, Rtng_MeanFmax_correctDetUns, MeanTTP_correctDetUns, Rtng_MeanTTP_correctDetUns, ErrorDetAlle, ErrorUndetAlle, CorrectDetAlle, FalseAlarmAlle,...
DoubleRt, PEMeandiffErDet, PCMeandiffCDet, PEMeandiffErUndet, PCMeandiffCUndet, PEMeandiffErDetFmax, PCMeandiffCDetFmax, PEMeandiffErUndetFmax, PCMeandiffCUndetFmax, PEMeandiffErDetTTP, PCMeandiffCDetTTP, PEMeandiffErUndetTTP, PCMeandiffCUndetTTP,...
PEA1, PEA2, PCA1, PCA2, MeanRtDistHigh, Rtng_MeanRtDistHigh, MeanRtDistLow, Rtng_MeanRtDistLow, MeanFDistHigh, Rtng_MeanFDistHigh, MeanFDistLow, Rtng_MeanFDistLow, MeanTTPDistHigh, Rtng_MeanTTPDistHigh, MeanTTPDistLow, Rtng_MeanTTPDistLow, conFr, conRt, conF, conTTP, conRt, conF, conTTP, bhcFFr, bhcFRt, bhcFF, bhcFTTP, whcFR, whcRt, whcF, whcTTP, bhcAFR, bhcARt, bhcAF, bhcATTP];
"Table" has been preallocated as
Table = zeros(all_n,123)
and vp is
vp = 1:all_n
The reason "Table" is defined as (all_n,123) is that it used to work with 123 before I entered many more variables into Table. So I thought I would have to change 123 to the number of variables Table actually contains, but that did not work. I cannot figure out how I can get rid of the error...it says:
"Subscripted assignment dimension mismatch.
Error in [name of the file] (line 1382)
Table(vp,:)= [FPRt, FPFM, FPTTP, FP_Freq,
Rt_mean,F_mean,TTP_mean,slowfreqRH,slowfreqWH,correctfreq,errorfreq,Stim_Efreq,... "
Can someone help me? I am quite the newbie at Matlab, so maybe it's something obvious that I simply fail to see... Thank you!
  댓글 수: 1
Guillaume
Guillaume 2018년 7월 13일
The reason for the error is most likely because [FPrt, FPFM, ..., bhcATTP] is not 123 columns.
You could check what size it actually is by adding an additional step:
allvars = [FPrt, FPFM, ... %edit this line to have all your variables
assert(numel(allvars) == 123, 'Actual number of elements is %d', numel(allvars));
Table(vp,:) = allvars;
However, the fact that you want to concatenate so many variables is a flaw in the design of your code. So much better would be to rewind a bit and tell us how these variables came to be. Then we can find a better way (most likely faster and simpler) of doing what you want.
I would suggest that you use actual matlab tables to store all your data rather than matrices.

답변 (1개)

Walter Roberson
Walter Roberson 2018년 7월 13일
Change the left hand side to just
Table
With no subscript.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by