Presentation is loading. Please wait.

Presentation is loading. Please wait.

MATLAB 程式設計 Learning Arrays and x-y Plotting 方煒 台大生機系.

Similar presentations


Presentation on theme: "MATLAB 程式設計 Learning Arrays and x-y Plotting 方煒 台大生機系."— Presentation transcript:

1 MATLAB 程式設計 Learning Arrays and x-y Plotting 方煒 台大生機系

2 MATLAB 程式設計 Ex4_2 xy Plots, Labels, and Titles dx=.01; x=.5*dx:dx:10-0.5*dx; y=sin(5*x); plot(x,y, ’ r- ’ ); nhalf=ceil(length(x)/2); plot(x(1:nhalf),y(1:nhalf), ’ b- ’ ) plot(x(nhalf:end),y(nhalf:end), ’ b- ’ ) xlabel( ’ \theta ’ ) ylabel( ’ F(\theta) ’ ) title( ’ F(\theta)=sin(5 \theta) ’ ) s=sprintf( ’ F(\\theta)=sin(%i \\theta) ’,5) title(s)

3 MATLAB 程式設計 Ex4_3 Overlaying Plots close y2=cos(x); % the second function % plot both plot(x,y, ’ r- ’,x,y2, ’ b- ’ ) close all; plot(x,y, ’ r- ’ ) hold on plot(x,y2, ’ b- ’ ) Hold off

4 MATLAB 程式設計 Ex4_4 xyz Plots: Curves in 3-D Space clear;close all; dphi=pi/100; % set the spacing in azimuthal angle N=30; % set the number of azimuthal trips phi=0:dphi:N*2*pi; theta=phi/N/2; % go from north to south once r=1; % sphere of radius 1 % convert spherical to Cartesian x=r*sin(theta).*cos(phi); y=r*sin(theta).*sin(phi); z=r*cos(theta); % plot the spiral plot3(x,y,z, ’ b- ’ ) axis equal

5 MATLAB 程式設計 Ex4_5 Logarithmic Plots x=0:.1:8; y=exp(x); semilogx(x,y); title( ’ Semilogx ’ ) pause semilogy(x,y); title( ’ Semilogy ’ ) pause loglog(x,y); title( ’ Loglog ’ )

6 MATLAB 程式設計 Ex4_6 Generating Multiple Plots x=0:.01:20; f1=sin(x); f2=cos(x)./(1+x.^2); figure plot(x,f1) figure plot(x,f2)

7 MATLAB 程式設計 Ex4_7 Controlling the Axes close all; x=.01:.01:20; y=cos(x)./x; plot(x,y) axis([0 25 -5 5]) plot(x,y) xlim([ 0 25]) plot(x,y) ylim([-5 5]) axis equal

8 MATLAB 程式設計 Ex4_8 Greek Letters, Subscripts, and Superscripts \alpha \beta \gamma \delta \epsilon \phi \theta \kappa \lambda \mu \nu \pi \rho \sigma \tau \xi \zeta Θ 1 is coded with \theta_1 Θ 12 is coded with \theta {12} Θ 10 is coded with \theta ^{10} text(10,.5, ’ Hi ’ );


Download ppt "MATLAB 程式設計 Learning Arrays and x-y Plotting 方煒 台大生機系."

Similar presentations


Ads by Google