not able to calculate mean within the selected range
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi i have to calculate min,max and mean of y-axis within a range selected in x-axis.for range min and range max i have created 2 editboxes using guide .and am using one push button,when i push the button it should calculate min,max and mean of selected range and display in other 3 editboxes created for display.here is my code.please help
x=0:1:200;
data=get(handles.uitable1,'data');%200*4 matrix
one=data(:,2);
x1= get(handles.min,'string') %value entered in editbox of tag min
x2= get(handles.max,'string') %value entered in editbox of tag max
range =[x1 x2]
start_pt = min( find( x >= range(1) ) )
end_pt = max( find( x <= range(2) ) )
y_in_range = one(start_pt:end_pt);
%min,max,mean
max_one = max(y_in_range)
min_one = min(y_in_range)
mean_one=mean(y_in_range)
set(handles.minimum, 'String',min_one)
set(handles.maximum, 'String',max_one)
set(handles.mean, 'String',mean_one)
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 11 Fév 2013
Modifié(e) : Azzi Abdelmalek
le 11 Fév 2013
x1= get(handles.min,'string')
% is a string variable. Use instead
x1= str2double(get(handles.min,'string'))
%the same thing to store your data in a string property
set(handles.minimum, 'String',num2str(min_one))
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur View and Analyze Simulation Results 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!