
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

x = 6; y = 3; z = x / y; x = x - y; y = z + 2 * x;
What are the final values for
x: y: z:
phi = 2pi; theta = phi/2; st = sin(theta); val = exp(st); % theta = 2theta; cos(theta) What are the final values for
theta: ct: val: ans:
Complete the following function so that it produces the desired output.
function [x,y] = swap(x,y) % This function should swap the values of two variables. % If you want, you can use extra variables.
Now assume that the above function is stored in our current working directory and it is named swap.m. On the command window if we enter the following lines,
x = 0; y = 4; z = 5; [x,y] = swap(x,y); [z,r] = swap(x,z); swap(y,r);
What will be the stored values for
x: y: z: r: ans: