Use $integral $ and $fzero$ with ksdensity
1 次查看(过去 30 天)
显示 更早的评论
Hello, I have been looking for finding the intersection of two outputs of ksdensity, as well as integrating the difference of the two questions. Can you please see the code, you might understand what I am trying to say:
xlsread('Sheet1.xlsx','Hourly Data','B:B'); % load Data
Load = xlsread('Sheet1.xlsx','Hourly Data','D:D'); %load Data
[f_re,xr] = ksdensity(RE); % to return the 1st pdf
[f_lo,xl] = ksdensity(Load); %returns the 2nd pdf
figure
plot(xl,f_lo,xr,f_re); % plot
f1=@(x) f_re(x); % and starting from this line , things are getting complicated
f2=@(x) f_lo(x);
Pl=fzero(f1-f2,0); % trying to find the intersections of the two functions may be
q = integral(f1-f2,0,inf); % integrating the difference ?
And obviously, Matlab does return errors. I do not know how to do all of this, Could you please give me some hints! Thank you so much.
0 个评论
采纳的回答
Walter Roberson
2016-9-29
Pl=fzero(@(x) f1(x)-f2(x),0); % trying to find the intersections of the two functions may be
q = integral(@(x) f1(x)-f2(x),0,inf); % integrating the difference ?
You cannot add or subtract function handles: you have to call the function handles with arguments and add or subtract the results.
2 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!