MATLAB 2017b
Write a program which will:
Accept three numbers from the user: a, b and c which can assume any value.
Accept Dx and Dy for the calculations of the function
Write a function which accept a, b, c, Dx and Dy and will draw the following surface
Where x and y vary in the range of -10?x?10 -10?y?10.
Allow the user to rerun the program and exit the program upon request.
Code
clc
clear all
while(1)
a=input("Enter Value of a=");
b=input("Enter Value of b=");
c=input("Enter Value of c=");
Dx=input("Enter Value of Dx=");
Dy=input("Enter Value of Dy=");
myfunction = @(x,y) (a*x.^2 + b*y.^2+c*x+Dx*Dy);
[X,Y] = meshgrid(-10:.5:10);
Z = myfunction(X,Y);
surf(X,Y,Z);
colorbar;
xlabel("X value");
ylabel("Y value");
zlabel("Function");
m=input('Do you want to rerun code, Y/N [Y]:','s');
if m=='N'
break
end
end
Output:-
Enter Value of a=0.5
Enter Value of b=22
Enter Value of c=0.75
Enter Value of Dx=1
Enter Value of Dy=25
Do you want to rerun code, Y/N [Y]:
Plot:-
Get Answers For Free
Most questions answered within 1 hours.