Skip to content

Instantly share code, notes, and snippets.

@dangpzanco
Last active September 12, 2016 00:37
Show Gist options
  • Save dangpzanco/b119e69c06d814e2c39c42f57bdb882b to your computer and use it in GitHub Desktop.
Save dangpzanco/b119e69c06d814e2c39c42f57bdb882b to your computer and use it in GitHub Desktop.
% colocar o arquivo na pasta Documents/MATLAB
% executa a função no MATLAB apertando F5
clc % limpa a linha de comando
close all % fecha os graficos (se tiver)
clear all % limpa as variáveis
% cria primeira função
% os .* e .^ são pro caso de x ser um vetor,
% esses operadores realizam as contas elemento à elemento
f = @(x) 2*x.*cos(2*x) - (x-2).^2;
% cria segunda função
p2 = @(x) x(2) - f(x(2))*(x(2)-x(1)) / (f(x(2))*-f(x(1)));
% cria vetor de entrada para p2(x)
x = [3, 2];
% printa o valor no terminal
p2(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment