I have written a function for spherical harmonics in which I want to control the ' Plotting area ' in such a way that, when we call the function into a variable, (i.e, lets say variable X= Plt( 10,30)*) I don't wanna show the plotting part. Otherwise (i.e, if the function _ Plt(10,30)* calling in a command window or somewhere in any other scripts, the plotting part of the function should run/ show the plots. The code has given below. (I have also attached the Plt.m* file with this.) Please give me an idea/ answer…. Thanks in advance.!
function [ P_bar ] = Plt( Degree_or_Order, Theta_In_Degree ) %%Content
%---------------------------------Plotting of Data--------------------------------
if grid_legth>1 % Works if ''theta'' is a grid of angles.
r=0; for m=0:M figure; width=1; for L=r:L_max PP=reshape(P_bar(L+1,m+1,1:grid_legth),1,grid_legth); plot(T,PP,'linewidth',(1+(width/10)),'Color',rand(1,3)); hold on; grid on; width=width+1; end title(['Plote of P_(_:_,_' num2str(m) '_)']); xlabel('Co-Latitude[Degree]'); [Lidx,Midx] = ndgrid(r:L_max,m); legends = cellstr(num2str([Lidx(:),Midx(:)],'L = %d, M = %d')); legend(legends,'Location','NorthEastOutside'); r=r+1; end figure; PP=reshape(P_bar(L_max+1,M+1,1:grid_legth),1,grid_legth); plot(T,PP,'linewidth',2); grid on; xlabel('Co-Latitude[Degree]'); title(['Plote of P(' num2str(L_max) ',' num2str(M) ')']); elseif grid_legth==1 % Works for a perticular co-latitude.
figure; for m=0:M a = linspace(10,150,L_max+1); scatter(0:L_max,P_bar(:,m+1),a,'filled'); hold on; grid on; end [Midx] = ndgrid(0:M); legends = cellstr(num2str([Midx(:)],' M = %d')); legend(legends,'Location','NorthEastOutside'); title(['Scatter of P(' num2str(L_max) ',' num2str(m) ') with theta= ' num2str(T) ' degree']); xlabel('Degree of Legendre Function (0 to L_m_a_x)'); end end
Best Answer