1 / 5

Matlab for and while loops

clearclose allclcformat compact A = 5; % initial amplitudeT = 1/60; % period of oscillationtau = 2*T; % attenuation envelope time constanttTotal = 8*T; % total timen = 1000; % total points dt = tTotal/(n-1); for i = 1:1:n t(i) = (i-1)*dt; a(i) = A*exp(-t(i)/tau); f(i) = a(i)*sin(2*pi*t(i)/T);end plot(t,f,'-xk', t,a,'--r', t,-a,'--r');title('Damped Oscillator');xlabel('time (s)');ylabel('amplitude');.

lois
Download Presentation

Matlab for and while loops

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. Matlab ‘for’ and ‘while’ loops This presentation should be viewed as a slideshow. Use the alt-tab key combination to switch between the slideshow and Matlab as you work through the examples. Pay close attention to each program step and explanation. Be sure that you understand the purpose of each program instruction. It is not a typing exercise.

More Related