I need help with a matrix input and a vector output! please !!
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello ! I had written all the question here, but for some reasom my computer shut Down.. and i did not save it, so i have attached a Picture of the description instead of writing it down Again. Please see the attached image! : "help matlab.jpg"
I wrote a code as follows:
%(EXAMPLE: a Matrix, lets call it S, like:
| Studentnumber| Name | grade1 | grade2 | grade3 | grade4 |
| S1 | JACK | 2 | 2 | 4 | 7 |
| S2 | RYAN | 10 | 7 | 10 | 7 |
| S3 | PETER| 7 | 7 | 4 | 7 |
| S4 | HARRY| 12 | 10 | 10 | 12 |
| S5 | WILL | 2 | 0 | -3 | 4 |
| S6 | LEIF | 10 | 7 | 4 | 7 |
%For each condition i will use an IF/else function.
If s(:,i) = 1;
finalValue = s(:,i,1);
% for the second condition: ( first the lowest element is removed by MIN
% function and then the average of the rest of the numbers is calculated by MEAN.
elseif s(:,i) > 1
f = min(s(:,i) - s(:,i)
final value = mean(f)
% for the last condition if any of the grades = -3, the final value = -3.
elseif s(:,i)==-3
finalValue = -3.
end
end
(I also thought about using a for loop to run through each row of the matrix, but when i do so the names get "used" to and matlab displays an error. if i for instance use a csv file containing only the numbers then it will Work with a for-loop. But since i need to used csv file with the studentnumber, and names, it won't Work)
The final output should be a vector with length N, containing the final value for each student. Can someone out there please help me out with this ? I will really appreciate it!
Also the values of the grades can only be those of the 7- step - scale: [-3, 0, 2, 4, 7, 10, 12] And the purpose of the script is to run a csv file containing the matrix and then evaluate the answers.
Thanks for your time !
9 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements 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!