surf plot won't happen because i need a matrix?
Show older comments
surf plot won't happen because i need a matrix? I've just introduced a new variable to my script and I tried doing it using a nested loop. Only problem is that when I tried to plot a surface graph it says I should be using a matrix - not a scalar or vector. I just added the variable G - which is angle.
iter=1;
for f=50:1000
for G=0:(pi/2)
rho_a=1.2041;
c=343.26;
L=0.1;
a=0.03;
sigma_pf1=10000;
phi_pf1=0.96;
alpha_pf1=1;
k_a=(2*pi*f)/c;
k_pf1=((2*pi*f)/c)*sqrt(alpha_pf1-((1i*sigma_pf1*phi_pf1)/(2*pi*f*rho_a)));
zc_air=rho_a*c;
zc_pf1=((rho_a*c)/phi_pf1)*sqrt(alpha_pf1-((1i*sigma_pf1*phi_pf1)/(2*pi*f*rho_a)));
zs_pf1=(-1i)*((cos(k_pf1*L)*cos(k_a*a)-(zc_pf1/zc_air)*sin(k_pf1*L)*sin(k_a*a))/((1/zc_pf1)*sin(k_pf1*L)*cos(k_a*a)+(1/zc_air)*cos(k_pf1*L)*sin(k_a*a)));
Rs_pf1=((zs_pf1/(rho_a*c))*cos(G)-1)/(1+(zs_pf1/(rho_a*c))*cos(G));
AbsCoef_pf1=1-(real(Rs_pf1))^2;
Rs_pf1rec(iter)=Rs_pf1;
AbsCoef_pf1rec(iter)=AbsCoef_pf1;
zs_pf1rec(iter)=zs_pf1;
iter=iter+1;
end
end
surf(50:1000,0:(pi/2),AbsCoef_pf1rec,'color','g');
set(hleg,'Location','SouthEast');
set(hleg,'FontSize',16);
set(gca,'FontSize',16);
Any help would be great.
Accepted Answer
More Answers (0)
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!