How can I call a function to draw histogram in GUI?
2 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Steven Lord
on 15 Nov 2017
"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 Comments
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!