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

2. Create a matrix M that looks like the following: Using nested for loops and i

ID: 3778505 • Letter: 2

Question

2. Create a matrix M that looks like the following: Using nested for loops and if statements, and use fprintf to show the matrix 8 11 14 17 ME 1 0 11 14 17 2 0 14 4 3. Write a script that will evaluate the f(x,y) for any user specified values for x, and y x y x 0 and y 0 x y x 20 and y 0 f(x, y) x t y x 0 and y 2 0 (x2 ty x 0 and y 0 Ask the user how many values they want to enter. Then the user has to be able to enter values for x and y and then the evaluated function should be printed out together with the values entered. Set up a table with x, y and f and print on the end of the script.

Explanation / Answer

2)

% this is for user input
input('enter the array ele: ');
for row=1:1:3 % rows are 3
  
for col=1:1:5 % column are 5
arr(row,col)=input('enter: ');
end
end

% for print the desired array
input(' the resulted array ele are:');
for row=1:1:3 % rows are 3
  
for col=1:1:5 % column are 5
fprintf('%d ',arr(row,col));
end
fprintf(' ');
end

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

3)

n=input('how many values u wnt to enter for x and y::');
for i=1:1:n

x=input('enter the val for x:');
y=input('enter the val for y:');

if (x>=0&&y>=0)
f=x+y;
fprintf('%d',f);

elseif(x>=0&&y<0)
f=x+y^2;
fprintf('%d',f);
  
elseif(x<0&&y>=0)
f=x^2+y;
fprintf('%d',f);
  
elseif(x<0&&y<0)
f=x^2+y^2;
fprintf('%d',f);
end
fprintf(' value of x:%d,value of y:%d,value of f:%d',x,y,f);
end

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote