not able to calculate mean within the selected range
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Azzi Abdelmalek
2013-2-11
编辑:Azzi Abdelmalek
2013-2-11
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))
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!