how use the for loop and stem function

1 vue (au cours des 30 derniers jours)
Alexandre Williot
Alexandre Williot le 8 Mar 2015
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.

Réponse acceptée

Alexandre Williot
Alexandre Williot le 17 Avr 2015
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')

Plus de réponses (0)

Catégories

En savoir plus sur Develop Apps Using App Designer 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!

Translated by