Math 244: MATLAB Assignment 1 Name: RUID: Date: clear; close all; clc; 1. % Define variables and computations here x = 6; y = 5; sol1 = x*y sol1 = 30 sol2 = (x^2) + (y^2) sol2 = 61 sol3 = x/(3*y) sol3 = 0.4000 2. % Display commands here disp(['The number x is ' num2str(x) '.']); The number x is 6. disp(['The number y is ' num2str(y) '.']) The number y is 5. disp(['The number xy is ' num2str(x*y) '.']) The number xy is 30. 3. % Generates a random number between 1 and 100 randNum = randi(100, 1) randNum = 98 1 % Write the if statements here if mod(randNum,2) == 0 disp(['The number ' num2str(randNum) ' is even.']) else disp(['The number ' num2str(randNum) ' is odd.']) end The number 98 is even. 4. % Define a vector that will contain the Fibonacci numbers fib = zeros(1,20); % Initial conditions fib(1,1) = 1; fib(1,2) = 1; % Write the for loop here for i=3:length(fib) fib(1,i) = fib(1,i-2) + fib(1,i-1); end % Display the vector disp(fib) 1 1 2 3 5 5. xVals = linspace(0, 3, 1000); % Define the functions f and g f = sin(xVals); g = xVals - 1; % Plot the graph of f hold on plot(xVals, f, 'blue') hold off 2 8 13 21 34 figure(); % Plot the graph of g hold on plot(xVals, g, 'red') hold off figure(); % Plot the graph of f and g together hold on plot(xVals, f, 'blue') 3 plot(xVals, g, 'red') hold off figure(); 6. % Define function and use quiver244 here. f = @(t,y)(t-(y.^2)); quiver244(f,0,5,-3,10,'blue') 4 figure(); disp('With all three starting points (y(0)=3, y(0)=0, & y(0)=8), y approaches the same value, however, they take different paths. For example, y(0)=3 & y(0)=8 take l/u-shaped paths, whereas y(0)=0 takes an s-shaped path.') With all three starting points (y(0)=3, y(0)=0, & y(0)=8), y approaches the same value, however, they take different 7. % Code for sample plots here f = @(t,y)(t-(y.^2)); hold on samplePlots244(f,0,5,-3,10,0,3,'blue') samplePlots244(f,0,5,-3,10,0,0,'red') samplePlots244(f,0,5,-3,10,0,8,'green') hold off 5 disp('Yes, these graphs do support my thoughts in the previous part. Both the green and blue graphs have a sort of l/u-shaped curve, whereas the red graph is closer to being s-shaped') Yes, these graphs do support my thoughts in the previous part. Both the green and blue graphs have a sort of l/u-sha 6