# integral solver give a function as result

1 view (last 30 days)
Gianluca Angelini on 13 Nov 2023
Answered: Ishu on 27 Nov 2023
Hi everybody, I am trying to solve my code by using the integral solver of Matlab, since I need to guarantee an energetic equivalence between two graphs. But the result isn't satisfying. The thing is that I cannot understand what's going wrong.
this is the code:
Sig_Height=0.0213*(vel_wind_R^2);
T_zc=0.519*vel_wind_R;
AA=4*pi^3*(Sig_Height/(T_zc^2))^2;
BB=16*pi^3*(1/(T_zc)^4);
syms freq_wave;
Spectre=AA/(freq_wave^5)*exp(-BB/(freq_wave^4)); %Bretschneider's spectre
integral=int(Spectre/(1-2*freq_wave*cos(teta_1rad)/g),0,inf);
Spectre_e=double(integral);
integral_2=int(freq_wave-(freq_wave^2*vel_nave/g)*cos(teta_1rad),0,Inf);
freq_e=double(integral_2);
I specify that:
vel_wind_R= 6.7; teta_1rad= 1.04; g=9.81.
Thanks in advance to whoever will give me support.
##### 0 CommentsShow -2 older commentsHide -2 older comments

Sign in to comment.

### Accepted Answer

Ishu on 27 Nov 2023
Hi Gianluca Angelini,
I understand that you are trying to solve the equations using "integral" but in the provided code you have not used the "intergral" of MATLAB anywhere.
I tried to reproduce the error at my end and I found that "double()" is not used properly. The functionality of "double()" is to convert symbolic values into doubles but as in the equations there is no value provided for "freq_wave" symbolic varible so it gives error. Therefore, before using "double()" you should use "subs()" to assign a symbolic value to "freq_wave" and then use "double()".
vel_wind_R= 6.7;
teta_1rad= 1.04;
g=9.81;
Sig_Height=0.0213*(vel_wind_R^2);
T_zc=0.519*vel_wind_R;
AA=4*pi^3*(Sig_Height/(T_zc^2))^2;
BB=16*pi^3*(1/(T_zc)^4);
syms freq_wave
Spectre=AA/(freq_wave^5)*exp(-BB/(freq_wave^4)); %Bretschneider's spectre
integral=Spectre/(1-2*freq_wave*cos(teta_1rad)/g);
Spectre_e=subs(integral, freq_wave, pi); % replace freq_wave with pi
Spectre_e2 = double(Spectre_e)
Spectre_e2 = 0.0036
You can refer below documentations for more information:
Hope it helps.
##### 0 CommentsShow -2 older commentsHide -2 older comments

Sign in to comment.

R2018b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!