0

i'm having some issues starting off with matlab and the articultion with function files. i have been asked the following. "write a user defined MATLAB function file for the following function z = (x^2 + 1)(y^2 - x) The inputs of the function are x and y and the output is z. Name the function as q2_func. write the function so that x and y can be vectors.

A) use the function q2_func to calculate and display the value of z for x=-3 and y = 3. B) use the function q2_func to calculate and display the value of z for x=[1 2] amd y = 3.

So far for my function file I have the following

function [ z ] = q2_func(x, y) x = (x.^2 + 1)*(y.^2 - x); end

and for the actual matlab programming x1 = q2_func(-3, 3)

when I hit run I get the error undefined function 'q2_func' for input arguments type double

What am I doing wrong so far? any help appreciated, thanks

0

1 Answer 1

2

First, there is a mistake in your function, it should be z = (x.^2 + 1).*(y.^2 - x);.

Second, have you saved your function as q2_func.m in your current directory or somewhere on the MATLAB path? The error message indicates that MATLAB cannot find the file.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.