フィルターのクリア

How can I call a function to draw histogram in GUI?

2 ビュー (過去 30 日間)
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD 2017 年 11 月 15 日
コメント済み: MAHMOUD ALZIOUD 2017 年 11 月 16 日
Dear all; I have a function written below, this function supposed to provide me with a histogram, when i push the button it must give a histogram in axes1, how can i do that please? knowing that the gui file and the function are in the same folder:
function SingleAxle = ALS_Single( Class9_data )
directory=dir('*.Y07');
for K = 1 : length(directory)
filename = directory(K).name;
fileID = fopen(filename,'r');
formatSpec = '%s';
A_cell = textscan(fileID,formatSpec);
A=char(A_cell{1,1}{:,:});
A(find(isnan(A)))=0;
[rows,columns]=size(A);
if columns~=105
ArrayTemp=zeros(rows,105);
ArrayTemp(1:rows,1:columns)=A;
A=ArrayTemp;
A=char(A);
A(isspace(A)) = '0';
end
Month_of_Data= A(:,14:15);
M=Class9_data;
figure
SingleAxle=100*Class9_data(:,14);
histogram(SingleAxle);
xlabel('Weight in Kg')
ylabel('Counts')
month(K)=unique(str2num(Month_of_Data));
months = month(K);
title(['ALS for C9 Single For Month ',num2str(months)])
end

回答 (1 件)

Steven Lord
Steven Lord 2017 年 11 月 15 日
Use this syntax from the documentation for histogram.
"histogram(ax,___) plots into the axes specified by ax instead of into the current axes (gca). The option ax can precede any of the input argument combinations in the previous syntaxes."
Pass the handle of the axes in the GUI as the first input and your data as the second.
  2 件のコメント
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD 2017 年 11 月 15 日
i was trying to handle and pass like this but it is not working: it keeps saying reference to non existing field. this is my gui fpushbutton function:
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
SingleAxle=100*Class9_data(:,14);
N= str2double(get(handles.SingleAxle, 'string'));
axes(handles.axes1)
ALS_Single (N);
h = figure();
histogram(h, N)
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD 2017 年 11 月 16 日
I modified it this way but still not working !!
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.SingleAxle=100*Class9_data(:,14);
N= str2double(get(handles.SingleAxle, 'string'));
axes(handles.axes1)
h = figure();
histogram(ax,h,N)

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

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by