Presentation is loading. Please wait.

Presentation is loading. Please wait.

EGR106 Week 5 MATLAB FILES Two Dimensional Plots Multiple Plots Plot Formatting Homework.

Similar presentations


Presentation on theme: "EGR106 Week 5 MATLAB FILES Two Dimensional Plots Multiple Plots Plot Formatting Homework."— Presentation transcript:

1 EGR106 Week 5 MATLAB FILES Two Dimensional Plots Multiple Plots Plot Formatting Homework

2 MATLAB Files Script files (m files) Text files Contain MATLAB commands Data Files (mat files) binary files Contain arrays (data) Use “save” and “load” commands to write and read

3 Two Dimensional Plots Line type plot(x,y,’--’) gives a dashed line Line color plot(x,y,’g’) gives a green line Line thickness Markers plot(x,y,’--r*’,’linewidth’,2,’markersize’,12) Dashed red line with * marker

4 Multiple Plots Plot(x, y1, x, y2) Plots y1 and y2 vs x hold on Keeps the plot window open for additional lines on the same plot hold off Stops writing to the plot subplot(n,m,k) Selects plot k in an nxm array of plots. Used for multiple plots on the same page.

5 Plot Formatting xlabel, ylabel xlabel(‘time (sec)’) title title(‘Problem 3 Solution’) text text(x,y,’your message at coordinates x,y’) legend legend(‘first curve’,’second curve’) –used for multiple curves on a single plot

6 Plot Formatting Subscripts and superscripts Greek letters Rotating text

7 >> x=0:2:10; >> y=x.^2; >> plot(x,y,'--r*','linewidth',2,'markersize',12) >> text(2,50,'\fontsize{30} \alpha Profit= x^2 ', 'rotation',45)

8 sound_in sound=data; % Note that data is a one column array with 8000 rows. echo(4001:12000,1)=sound; % The echo is the sound delayed 4000 units (4000/8000 sec) % Writing into rows 4001:12000 automatically % sets rows 1:4000 equal to zero. sound(8001:12000,1)=0; % Pad the end of the sound with zeros so echo and % sound are the same size. data= sound + 0.25*echo; % Attenuate the echo to 25% of the sound % and add it to the original sound. pause(2) % Wait 2 seconds to hear the sound plus the echo. sound_out

9 Array Addressing Store Audio number(:,1) = zero ; % store zero in column 1 number(:,2) = one; % additional digits are stored number(:,3) = two; % in column number + 1. Get User Number no = input('What is the first digit? ') data = number(:,no+1); % Read audio from memory no = input('What is the next digit? ') data = [data ; number(:,no+1)]; % build data array sound_out


Download ppt "EGR106 Week 5 MATLAB FILES Two Dimensional Plots Multiple Plots Plot Formatting Homework."

Similar presentations


Ads by Google