This is a MATLAB question. Please help show how to input it into an M file if yo
ID: 3928818 • Letter: T
Question
This is a MATLAB question. Please help show how to input it into an M file if you can. Will Rate Fast
Consider the following function: f(x, y) = x2 + xy-36 y +xe**1 +9 4X Allow the user to input values for both x and y as scalars. Only allow the function to evaluate if the value of x is less than or equal to y. If the function is evaluated, display the value of x and y as well as the function evaluation result using a single instruction. If not, show an appropriate error message to the user and do not allow the function to be evaluated. Evaluate your code at the following points: x =5,y=5 ii. x- 0.25,y-e3x 111. x = 0.2, y = VX-001 iv. x-1,y-5Explanation / Answer
//Tested on Octave online
clear all
debug_on_error (1)
warning('off','all')
N=4% total number of inputs
function [z] = expression(x,y)
%this function returns the value of expression
% It takes 2 input arguments
% which are the value of x, y and the
% It returns the value of expression
z=x^2+x*y-36*y+x*4*exp(4*x*x)+9
endfunction
for x = 0:N-1%for loop start
x=input("Please Enter x value")%prompt for x value
y=input("Please Enter y Value")%prompt for y value
if x<=y%x value less then or equal then it will enter
[result]=expression(x,y)
sprintf('X is %.2f,Y is %.2f ,Result is :%e',x,y, result)
else
disp('value of x is greater then Y')
end%end conditional
end %for loop end
/*************output**************/
Thanks a lot
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.