Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help writing this code for matlab fun 1 fun 2 1. The matlab function fun1.m defines a function f: R2R2. Write a matlab

I need help writing this code for matlab

image text in transcribed

fun 1

image text in transcribed

fun 2

image text in transcribed

1. The matlab function fun1.m defines a function f: R2R2. Write a matlab program called hwk1prob1.m that uses the matlab function fsolve to solve the equationf()0. Run your program, outputting your solution to the file hwk1out1.txt o Hints/suggestions To get help on using the fsolve function, type "help fsolve" at the matlab command prompt. To use fsolve, you will need to give a starting point x0, which represents an initial guess for the solution. You may need to try multiple starting points to find one that works. A simple way to generate your output file is to type "diary hwk1out1.txt" at the matlab command line and then run your program 2. The matlab function fun2 n defines a function f ; c) R2 R, defined by 3 parameters e c(1 c(2), (3) which are sp ec fied as input to the function. This function was used with a fixed choice of parameters c, to generate 10 data points of the form z J y J J 1 10, where z , : is a vector of length 2, representing the x coordinates of the jth data point, and y(j) f These 10 data points are given in the file data2.txt a. Write a matlab program hwk1prob2.m that uses fsolve to determine the parameters e that were used to generate the data. Run your program outputting the results to the file hwk1out2.txt oHints/suggestions . You might want to write a matlab function call "fresidualm Use fsolve to solve the equation r(c)-0. that calculates the residual r(c) = [n(c), . . . , ro(c)], where r(c) = f(z(j.); c)-y(j), j = 1, . . . , 10. function [ y ] -fun1(x) funl (x) evaluates the function f: R*2 - RA2 defined by f (x) - [f1 (x1, x2), f2 (x1, x2)] where f1 (x1, x2)tanh (2x1-3x2+1) f2(x1,x2) = exp (. 3x1+ .4 x2 )-4.7 % input x = vecto r of length 2: x=[x1, x2 ] % output y (fl (x) ,f2 (x)) -tanh (2*x ( 1 )-3*x (2)^2) +1; y(1) y(2) exp ( . 3tx ( 1 ) +.4*x (2))-4.7: end function [ y ] -fun2(x,c) % fun2(x) evaluates the function f: R"2--> R^2 defined by f (x) -f(x1, x2) -tanh (c1#x1+e2 *x2+c3 ) where c1,c2, and c3 are input parameters % input x vector of length 2: x=[x1 , x2] C- [c1 ,c2 , c3] vector of length 3 specifying the parameters % output yf (x1, x2) y tanh (c (1) *x (1) c(2) *x (2))) end

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions

Question

2. Describe how technology can impact intercultural interaction.

Answered: 1 week ago

Question

7. Define cultural space.

Answered: 1 week ago