1 / 9

EGR106 Week 5

EGR106 Week 5. MATLAB FILES Two Dimensional Plots Multiple Plots Plot Formatting Homework. 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.

kaden-craft
Download Presentation

EGR106 Week 5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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

More Related