Plotting a bivariate function and a tangent line on the same graph
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Scott Henley
le 10 Juil 2019
Réponse apportée : Star Strider
le 10 Juil 2019
I'm currently attempting to plot two functions, f(x,y) = x^2 + 3(x^2)y + 3 and 14(x-1) + 3(y-2) = 0, onto the same graph, however I'm finding extreme trouble (likely because of my inexperience) plotting the two simultaneously. The only part I understand thus far is that f(x,y) can't be converted to matrix form (required to plot in 3D) as it's not a linear function.
If someone is willing and able to walk me through the process of doing this, that would be greatly appreciated.
0 commentaires
Réponse acceptée
Star Strider
le 10 Juil 2019
To plot them simultaneously, you need to use the hold function.
See if this does what you want:
f = @(x,y) x.^2 + 3*(x.^2).*y + 3; % Anonymous Function
g = @(x,y) 14*(x-1) + 3*(y-2); % Anonymous Function
[X,Y] = ndgrid(linspace(-10,10, 250)); % Define Matrix Arguments
figure
mesh(X, Y, f(X,Y)) % Plot Surface
hold on
contour3(X, Y, g(X,Y), [0 0], 'Color','r', 'LineWidth',2) % Plot Implicit Function
hold off
grid on
view(30,30)
Experiment to get the result you want.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Digital Filter Analysis dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!