I want to make a function that plots 3D quadratic surface

34 visualizaciones (últimos 30 días)
Maryam Abdelhamid
Maryam Abdelhamid el 9 de Mayo de 2020
Comentada: Walter Roberson el 18 de Mayo de 2020
I want to creat a function that returns a graph of hyperbolic paraboloid just by entring the coefficient of x^2,y^2 and z
function hyperbolicparaboloid(A,B,C)
A=input('enter coeffecient of x^2');
B=input('enter coeffecient of y^2');
C=input('enter coeffecient of z');
%y^2/b^2-x^2/a^2=z/c
%where B=1/b^2, A=1/a^2, C=1/c
X=linspace(-10,10,100);
Y=linspace(-10,10,100);
Z=linspace(-10,10,100);
[X,Y]=meshgrid(X,Y);
Z=((Y.^2*B)-(X.^2*A))./C;
mesh(X,Y,Z);
view([130,30])
end
Althoug the code is working the function cannot be created
so what is the problem with this function?
  1 comentario
Walter Roberson
Walter Roberson el 9 de Mayo de 2020
What is the point of accepting three input parameters and then promptly ignoring them? You should either have your function not accept any parameters or else you should have your function use the A, B, C values passed in.
Z=linspace(-10,10,100);
That statement is not productive: you overwrite the Z you create there.

Iniciar sesión para comentar.

Respuestas (1)

rajat aggarwal
rajat aggarwal el 18 de Mayo de 2020
Editada: rajat aggarwal el 18 de Mayo de 2020
You can use ezplot to draw hyperbolic paraboloid
following links can also help
clc;
clear all;
[X,Y,Z] = meshgrid(-10:0.5:10,-10:0.5:10,-10:0.5:10);
a=1;
b=1;
c=1;
V = X.^2/a^2 + Y.^2/b^2 - Z.^2/c^2;
p=patch(isosurface(X,Y,Z,V,1)); % This is the key step. It involves getting the part of the volume corresponding to the surface defined by the equation
set(p,'FaceColor','red','EdgeColor','none');
daspect([1 1 1])
view(3);
camlight
  1 comentario
Walter Roberson
Walter Roberson el 18 de Mayo de 2020
Note that ezplot() is not recommended anymore. It uses older technology to create the plot. fplot() is a better choice in most cases now.

Iniciar sesión para comentar.

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by