Last active
September 12, 2016 00:37
-
-
Save dangpzanco/b119e69c06d814e2c39c42f57bdb882b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% 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