Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Function 1: Function 2: I need help writing a matlab program to run these functions. I created a program for both, but on the first

image text in transcribed

Function 1:

image text in transcribed

Function 2:

image text in transcribed

I need help writing a matlab program to run these functions. I created a program for both, but on the first program when I try running it, it gives me an error saying not enough input arguments in line 4.

This is the the first program.

function [y] = fun1(x) myfun = @(x)[tanh(2*x(1)-3*x(2)^2)+1; exp(.3*x(1)+.4*x(2))-4.7]; y = fsolve(myfun, x);

This is the second program I wrote and it has the same error as the first one.

function [y] = fun2(x,c) myfun = @(x) tanh(c(1)*x(1) + c(2)*x(2) + c(3) ); y = fsolve(myfun,x);

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

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

More Books

Students also viewed these Databases questions

Question

7. Define cultural space.

Answered: 1 week ago

Question

8. Describe how cultural spaces are formed.

Answered: 1 week ago