MATLAB INTRODUCTORY EXERCISE Create an M-file named userid_date (e.g. dfjackson_110606)

advertisement
MATLAB INTRODUCTORY EXERCISE
Create an M-file named userid_date (e.g. dfjackson_110606)
% MATLAB exercise 1 - Getting Started – Date
% Your Name
% EF105 Section:Monday8:00 TA - Ortal
>> diary lab1ex
>> 4+7+9
>> 4*7+9
>> 4*(7+9)
>> r=10
>> area=pi*r^2
>> r=[1 5 10 50 100]; % Now the variable r represents a list of 5 values.
>> area=pi*r.^2
>> r=1:10;
>> area=pi*r.^2; %Recompute the area for the new length 10 vector r.
>> plot(r, area) % Plot the new area values. Get a smoother plot with more
points.
>> plot(r, area,'x-') % Plot "x" and lines, omit the – to omit the lines.
>> title('My plot of area vs radius on November 6, 2006')
>> xlabel('radius in cm')
>> ylabel('area in square cm')
% A step size other than 1 can be used to automatically generate an array. For
a step of 1/2:
>> r= -2:0.5:10; % beginning value:step:final value
>> area=pi*r.^2; %Recompute the area for the new values of r.
>> plot(r, area,'o') % Replot with points marked with o and no lines.
% Now you write the coding to calculate velocity and acceleration based on the following
equations:
Velocity = 0.00001 time3 - 0.00488 time2 + 0.75795 time + 181.3566
Acceleration = 3 - 0.000062 velocity2
For times 0 to 120 by 10.
>> diary off % write the diary file and close it
>> exit % exit MATLAB
Download