unable to assign the classIds since there are different number of elements on both sides
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Shan Sha
am 6 Sep. 2018
Beantwortet: Walter Roberson
am 6 Sep. 2018
my error:Unable to perform assignment because the left and right sides have a different number of elements.
Error in tc14god>ReadOutexTxt (line 188) classIDs(i) = str2num(tline(index+5:end));
Error in tc14god (line 43) [trainIDs, trainClassIDs] = ReadOutexTxt(trainTxt);
I have attached my code with this. please help me to resolve the error. Thanks in advance
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 6 Sep. 2018
Your code does not protect against the possibility that the string you are converting is empty or has multiple numbers. str2num is essentially eval() of the string, able to return empty or a vector of values.
str2double on the other hand always returns a scalar even on empty inputń it returns nan if the input is not a scalar
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu String Parsing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!