Unable to perform assignment because the left and right sides have a different number of elements. Error in Assignment6ExcelCodyMadsen (line 44) letter(i) = 'B+' ; How do I fix this problem?
14 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
gradebook = xlsread('Exam_Grades_Data(1)');
display (gradebook);
%%Average Exam Grade for Each Student
% 0 - 59 = E
% 0 - 59 = E
% 0 - 59 = E
% 0 - 59 = E
% 0 - 59 = E
% loopend = length(x)
% loopend = length(grades)
i = 1:5;
average(i) = mean(gradebook(i,1:5));
temp = size(gradebook)
loopend = temp(1,1)
loopend = size(gradebook,1)
for i = 1:loopend
average(i) = mean(gradebook(i,1:5));
end
for i = 1:loopend
if (average(i) <= 59)
letter(i) = 'E' ;
elseif (average(i) <= 69)
letter(i) = 'D' ;
elseif (average(i) <= 75)
letter(i) = 'C' ;
elseif (average(i) <= 79)
letter(i) = 'C+' ;
elseif (average(i) <= 85)
letter(i) = 'B' ;
elseif (average(i) <= 89)
letter(i) = 'B+' ;
else
letter(i) = 'A' ;
end
end
display(Grades)
display(i)
display(average)
display(letter)
0 commentaires
Réponses (2)
Stephen23
le 10 Oct 2018
Modifié(e) : Stephen23
le 10 Oct 2018
What you are doing will not work: (i) refers to one element of the char array letter, and it is not possible to force multiple characters into one element of a char array: one element is one character. You can use a cell array to store those char vectors:
C = cell(1,loopend); % preallocate cell array.
for k = 1:loopend
if average(k) <= 59
C{k} = 'E';
... ^ ^ curly braces to access cell array contents
end
end
Read more:
Note that you don't need loops or switch for this task:
avg = mean(gradebook(:,1:5),2);
%avg = [0;23;45;67;89;100]; % test values
bin = [0, 60, 70, 75, 80, 85, 90, 100];
mrk = {'E','D','C','C+','B','B+','A'};
[~,idx] = histc(avg,bin);
idx = min(idx,numel(mrk));
out = mrk(idx)
0 commentaires
aqsa
le 31 Juil 2019
Unable to perform assignment because the size of the left side is 1-by-3377160 and the size of the right side is
1-by-3060288.plz help
3 commentaires
aqsa
le 31 Juil 2019
% Erxtecting Hog features for all training images and store in a vector
trainingFeatures= zeros(nImages,hogFeatureSize,'single');
for i=1: nImages
img=readimage(imdsTrain,i);
trainingFeatures(i,:)= extractHOGFeatures(img,'CellSize',CellSize);
end
trainingLabels=imdsTrain.Labels;
Walter Roberson
le 31 Juil 2019
The number of hog features is different for different sizes of images.
Voir également
Catégories
En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!