Join the curves and make them into one (overlap)
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
alpha=0.008;
gamma=3.3;
g=9.80665;
delta_1=0.07; % if f<=fp
delta_2=0.09; % if f>fp
Tp=[2 8 16];
fp_vector=1./Tp;
i_freq=1:69;
f1=0.03093;
c=1.1;
for i = 1:length(i_freq)
fi=f1.*c.^(i_freq-1);
end
f_vector=fi;
nrows = length(f_vector);
ncols = length(fp_vector);
E = ones(nrows,ncols);
fc = 0.4054;
for i = 1:nrows
for j = 1:ncols
f = f_vector(i);
fp = fp_vector(j);
if f<fc
if f<=fp
E(i,j) = (alpha*(g^2)*((2*pi)^(-4))*(f^(-5)))*exp((-5/4)*((f/fp)^(-4)))*gamma*exp((-1/2)*((f-fp)/(delta_1*fp))^2);
else
E(i,j) = (alpha*(g^2)*((2*pi)^(-4))*(f^(-5)))*exp((-5/4)*((f/fp)^(-4)))*gamma*exp((-1/2)*((f-fp)/(delta_2*fp))^2);
end
else
if f<=fp
E(i,j) = (fc/f)^5*(alpha*(g^2)*((2*pi)^(-4))*(f^(-5)))*exp((-5/4)*((f/fp)^(-4)))*gamma*exp((-1/2)*((f-fp)/(delta_1*fp))^2);
else
E(i,j) = (fc/f)^5*(alpha*(g^2)*((2*pi)^(-4))*(f^(-5)))*exp((-5/4)*((f/fp)^(-4)))*gamma*exp((-1/2)*((f-fp)/(delta_2*fp))^2);
end
end
end
end
E;
%%% Dir(teta)
i_teta=1:36;
teta_i=10.*i_teta;
teta_i_cos=cos(2*teta_i);
for i = 1:length(teta_i_cos)
if teta_i_cos>0
dir_teta=0;
else
dir_teta= (2/pi())*(1/2)*(1+teta_i_cos);%cos^2(x) = (1+cos2x)/2
end
end
dir_teta;
f_teta=teta_i;
%%% T=2s
T2=E(:,1);
for i = 1:length(T2)
for j = length(dir_teta)
Ef_teta_T2 = T2*dir_teta;
end
end
Ef_teta_T2;
%%% T=8s
T8=E(:,2);
for i = 1:length(T8)
for j = length(dir_teta)
Ef_teta_T8 = T8*dir_teta;
end
end
Ef_teta_T8;
%%% T=16s
T16=E(:,3);
for i = 1:length(T16)
for j = length(dir_teta)
Ef_teta_T16 = T16*dir_teta;
end
end
Ef_teta_T16;
surf(teta_i, f_vector, Ef_teta_T2);
title('T=2s');
xlabel('{\it\theta} [degree
]');
ylabel('{\itf} [Hz]');
zlabel('{\itE(f,\theta)}[m^2/Hz/degree]');
I wonder if I can join the curves and make one (overlap)? The code is above and the graphic that came out is below.
But I wanted the graphic to look like this:
Thank you for your help
0 Commenti
Risposte (1)
Star Strider
il 2 Nov 2020
It looks to me that it needs to be plotted in polar coordinates.
First, define:
i_freq=1:0.1:69;
and:
i_teta=1:0.1:36;
then after plotting the first figure add:
[Teta_im,F_vectorm] = meshgrid(teta_i, f_vector);
[X,Y,Z] = pol2cart(Teta_im, F_vectorm, Ef_teta_T2);
figure
surf(X, Y, Z, 'EdgeColor','none')
grid on
axis([-1.0 1.0 -1.0 1.0 zlim])
producing:
This is not exactly like the second image you posted, however it is close! I will let you add the axis labels and other information, and make any other necessary changes, since I have no idea what you are doing.
2 Commenti
Star Strider
il 2 Nov 2020
Modificato: Star Strider
il 2 Nov 2020
My pleasure!
If my Answer helped you solve your problem, please Accept it!
To only plot half of the surface, with the contour lines:
[Teta_im,F_vectorm] = meshgrid(teta_i, f_vector);
[X,Y,Z] = pol2cart(Teta_im, F_vectorm, Ef_teta_T2);
Lm = X > 0;
X(Lm) = NaN;
Y(Lm) = NaN;
z(Lm) = NaN;
figure
surf(X, Y, Z, 'EdgeColor','none')
hold on
contour3(X, Y, Z, 15, 'r')
hold off
grid on
axis([-1.0 1.0 -1.0 1.0 zlim])
view(145,35
producing:
.
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!