Skip to content

Instantly share code, notes, and snippets.

@dangpzanco
Last active June 17, 2016 00:27
Show Gist options
  • Save dangpzanco/1ec4a0a4ca242cfae42f0339f8d0430b to your computer and use it in GitHub Desktop.
Save dangpzanco/1ec4a0a4ca242cfae42f0339f8d0430b to your computer and use it in GitHub Desktop.
clc
close all
clear all
% numero de pontos
N = 500;
% funcao e sua derivada em relacao a x
f = @(x,y) log( x + (x.^2 + y.^2).^0.5 );
fx = @(x,y) (x.^2 + y.^2).^-0.5;
% intervalo do grafico
a = 0.1;
b = 5;
c = 0.1;
d = 5;
x = linspace(a,b,N)';
y = linspace(c,d,N)';
% gerar as matrizes de grid
[xx,yy] = meshgrid(x,y);
% gera as matrizes que definem f(x,y) e df(x,y)/dx
z = f(xx,yy);
dzx = fx(xx,yy);
% plotar as funcoes
mesh(xx,yy,z); shading interp
xlabel('x')
ylabel('y')
zlabel('z')
figure
mesh(xx,yy,dzx); shading interp
xlabel('x')
ylabel('y')
zlabel('z')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment