histfit, Reusing matlab auto generated code.
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi,
I am trying to get histfit plot for a vector. First i am using MATLAB plot tool to get required pot. But i want to use this in a loop so thats why i have generated m-code from ==> File ==> Generate M-File.
Problem is I don't get how to use it. Here is a short example:
v = [1:20];
histfit(v);
Here I get a plot, then go to File and generate M-file. After that i got following code:
function createfigure1(xvector1, yvector1, X1, Y1)
%CREATEFIGURE1(XVECTOR1,YVECTOR1,X1,Y1)
% XVECTOR1: bar xvector
% YVECTOR1: bar yvector
% X1: vector of x data
% Y1: vector of y data
% Auto-generated by MATLAB on 15-Mar-2011 14:36:01
% Create figure
figure1 = figure;
% Create axes
axes1 = axes('Parent',figure1);
box(axes1,'on');
hold(axes1,'all');
% Create bar
bar(xvector1,yvector1,'BarWidth',1);
% Create plot
plot(X1,Y1,'LineWidth',2,'Color',[1 0 0]);
Now the problem is if i wanna use this function then i have to give 4 input arguments and I need your help in that. Because in first step i was using just histft(v). So how to get these 4 input arguments from v.
Thanks in advance.
\\Arsalan
댓글 수: 0
채택된 답변
Kaustubha Govind
2011년 3월 15일
Here's one way of doing it:
h=histfit(v);
xvector1 = get(h(1), 'XData')
yvector1 = get(h(1), 'YData')
X1 = get(h(2), 'XData')
Y1 = get(h(2), 'YData')
createfigure1(xvector1, yvector1, X1, Y1)
Albeit, roundabout.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!