Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

need Matlab code for these questions that I am having trouble with....please mak

ID: 3849697 • Letter: N

Question

need Matlab code for these


questions that I am having trouble with....please make sure it works on Matlab r2016a


number. The display to the command window should look like the command Enter the real part of a complex number: -7 Enter the imaginary part of a complex number: 13 The magnitude and phase of -7+13i is where -7 and 13 were entered by the user. 3.5 The Fibonacci numbers can be generated from the relation V5 2 Generate the first 16 numbers using both fprintf and disp and present them MATLAB command window as follows: F 1 1 F 3 F15 610

Explanation / Answer

function fib()
for n=0:15 % n varies from 0 to 15. When nothing given between 0 and 15 step size is 1
sqrtoffive=sqrt(5); % store square root of 5 in a variable as it is used many times in the formula, so need not calculate again
f=1./sqrtoffive .* ( ((1+sqrtoffive)./2).^n - ((1-sqrtoffive)./2).^n ); % Formula. Always use .and then operator to convert it into scalar
fprintf('F%d= %0.0f ',n,f); % print using fprintf, same as printf in C. Give format specifier and then the variable name
X=['F',num2str(n),'= ',num2str(f)]; % Convert everthing to string and store in X
disp(X); % Display the string X
end % for loop ends

end % function ends

Run the following command in the command window:

fib

Comment any one of fprintf or disp to see the result only once