how use the for loop and stem function

3 次查看(过去 30 天)
Hello, I have a matrix with 3 columns (# of subjects, # of trials, scores). I have 10 subjects (with sometimes the value 999 as score). I need to calculate, for each subject, the mean score and the standard deviation without the value 999. Then, I need to trace the curve of the means for each subjects with the "stem" function. Finally, I have to trace the curve of standard deviation for each subject. I have no idea to do that. Can you help me please.

采纳的回答

Alexandre Williot
Alexandre Williot 2015-4-17
clc; clear all; close all;
%-- extraction des données du fichier xlsx -------------------------
[num,txt,raw] = xlsread('C:\Users\alexandre\Dropbox\UQTR 2013 - 2015\Matlab\MatLab EPK6064\Data_Level4_Exo3.xlsx');
%--création matrice Mat---------------------------------------------
Sujets = num(:,1);
Essais = num(:,2);
Scores = num(:,3);
Mat = [Sujets Essais Scores];
%-- RECHERCHE <20 ---------------------------------------------------------
pos_999 = [];
pos_999 = find(Mat(:,3)<20);
Mat(pos_999,3)= 999;
%-- Moyenne ---------------------------------------------------------------
for n=1:10
pos_suj = []
pos_suj = find(Mat(:,1) == n)
Mat_suj = []
Mat_suj = Mat(pos_suj,3)
pos_int = []
pos_int = find (Mat_suj~=999)
Mat_val=[]
Mat_val= Mat_suj(pos_int,1)
M_Mean(n,1) = mean (Mat_val)
M_std (n,1) = std (Mat_val)
end
%--graphique---------------------------------------------------------------
figure(1)
stem(M_Mean)
xlabel('sujet')
ylabel('moyenne')
title('graphique des moyennes')
figure(2)
stem(M_std)
xlabel('sujet')
ylabel('écart-type')
title('graphique des écart-types')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Quadratic Programming and Cone Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by