필터 지우기
필터 지우기

how use the for loop and stem function

조회 수: 1 (최근 30일)
Alexandre Williot
Alexandre Williot 2015년 3월 8일
답변: Alexandre Williot 2015년 4월 17일
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에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by