REC08+Problems+Set+Solutions

REC08+Problems+Set+Solutions - 14:440:127- Introduction to...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
14:440:127- Introduction to Computers for Engineers Problems for students to attempt in Recitation 8 1. For x running from 0 to 10, animate an X ±oating along the function y = 5x 2 – 3x. x = 0:0.1:10; y = 5*x.^2 - 3*x; for k=1:length(x) plot(x(k),y(k),'X') axis([min(x) max(x) min(y) max(y)]) pause(0.01); end 2. Repeat the problem above, but leave a trail after the X. x = 0:0.1:10; y = 5*x.^2 - 3*x; for k=1:length(x) plot(x(1:k),y(1:k),'X') axis([min(x) max(x) min(y) max(y)]) pause(0.01); end 3. For t running from 0 to 100, animate (and leave a trail) x(t) = (20-t)sin(t) and y(t) = (t-50)cos(t). t = 0:0.1:100; x = (20-t).*sin(t); y = (t-50).*cos(t); for k = 1:length(x) plot(x(1:k),y(1:k)) axis([min(x) max(x) min(y) max(y)]); pause(0.01) end 4. Animate the 3-D surface –x2 –y2 for increasingly large numbers of points. (i.e. ²rst graph x=[-1,1], y=[-1,1]… then graph x=[-2,2], y=[-2,2]… then graph x=[-3,3], y=[-3,3],….) for k = 1:30 [x y] = meshgrid(-k:k); z = -x.^2 - y.^2; whos surf(x,y,z) pause(0.2) end
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
% If you set the axis, it looks kind of like a parachute: [x y] = meshgrid(-30:30); z = -x.^2 - y.^2; minz = min(min(z)); maxz = max(max(z)); for k = 1:30 [x y] = meshgrid(-k:k); z = -x.^2 - y.^2; whos surf(x,y,z) axis([-30 30 -30 30 minz maxz]) pend 5. Create a plot of the function: y = sin(x) for x from -2 π to +2 π Assign the plot a handle, and use the set function to change the following properties (if you aren ʼ t sure what the object name is for a given property, use the get function to see the list of available properties): a) line color from blue to green b) line style to dashed c) line with to 2 x=-2*pi:pi/10:2*pi; y=sin(x); h=plot(x,y) get(h) %a set(h,'Color','green') %b set(h,'LineStyle','--') %c set(h,'LineWidth', 2) % or you could do it all in one statement set(h,'Color','green','LineStyle','--','LineWidth',2) 6. Create an animation of the function: y = sin(x-a) for x ranging from -2 π to +2 π and a ranging from 0 to 8 π
Background image of page 2
- Use a step size for x that results in a smooth graph - Let a be the animation variable (Draw a new picture for each value of a)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/24/2011 for the course PHYSICS 123 taught by Professor Madey during the Spring '08 term at Rutgers.

Page1 / 8

REC08+Problems+Set+Solutions - 14:440:127- Introduction to...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online