How to integrate for a data set ?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dear All,
I want to integrate the following equation
![Screenshot (35).png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/207339/Screenshot%20(35).png)
I have the data set of P(hw) and hw. I want to input the value E_g. Data set is given in the excel sheet
0 Kommentare
Antworten (1)
Star Strider
am 7 Mär. 2019
I have no idea what you are doing.
Try this:
filename = 'solar_spectrum.xlsx';
[D,S,R] = xlsread(filename);
Phw = D(:,1);
hw = D(:,2);
E_g = hw >= 0.5; % Logical Index — Choose ‘E_g’ (Here: 0.5)
S = trapz(hw(E_g), Phw(E_g))
figure
plot(hw, Phw)
hold on
patch([hw(E_g) fliplr(hw(E_g))], [Phw(E_g) fliplr(Phw(E_g))], 'y')
hold off
grid
producing:
S =
2.0305
The plot shows the approximate area covered by the integration.
Experiment to get the result you want.
1 Kommentar
Siehe auch
Kategorien
Mehr zu Numerical Integration and Differentiation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!