Use $integral $ and $fzero$ with ksdensity
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Imane Imane
am 29 Sep. 2016
Kommentiert: Walter Roberson
am 29 Sep. 2016
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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 29 Sep. 2016
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 Kommentare
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!