フィルターのクリア

not able to calculate mean within the selected range

2 ビュー (過去 30 日間)
rafi abdul
rafi abdul 2013 年 2 月 11 日
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)

採用された回答

Azzi Abdelmalek
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))
  1 件のコメント
rafi abdul
rafi abdul 2013 年 2 月 11 日
thank you.its working

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by