• Register
1 vote

Problem :

I am very new to Matlab. I have written below code in my .M file:

function f = piecewise(w, C)

I have already stored my file (piecewise.M) in my normal Matlab path, and so my assumption is that the Matlab will read my function when it will start and so my function must be available to be used.

But when I type below command

>> piecewise(w, C)

I start facing below error.

Undefined function 'piecewise' for input arguments of type 'double'.

Can you please help me in fixing above error?

8 5 2
3,230 points

Please log in or register to answer this question.

1 Answer

1 vote

Solution :

I think your problem is most probably the problem related to path of your function file not present in the Matlab's 'path'.

So to verify this you just need to open your function in your Editor and then you should press the F5 key. It will make your Editor to try and run your file and if your file is not in the path then it will surely prompt you with the message box. Like Choose Add to Path in that and after that you must be fine to go

And from now onwards you will be able to use your function from your command line giving a correct set of arguments.

8 4
5,680 points

Related questions

0 votes
1 answer 23 views
I wonder if you could change the value of an external input variable that is treated as a function parameter, I remember seeing a way to do it but I don't remember very well. Suppose we use a function for the sum of two numbers, which has two parameters, the first ... of the sum =" << number << endl; The result of the sum should be stored in the variable. Would this procedure really work?
asked Oct 1, 2020 sasha 13.2k points
0 votes
1 answer 29 views
Problem: write two nested for loops to calculate the following double summation
asked Feb 12 Dan phillip 1.9k points
0 votes
1 answer 81 views
Problem: I want to plot complex numbers. They have real and imaginary numbers in them. I want to plot all of them. Basically I have a function that gives me imaginary numbers as well and I want to plot that. Please help if you understand.
asked Oct 22, 2020 Ahsan 1.8k points
0 votes
1 answer 14 views
Problem: iu must be specified for systems with more than one input.
asked Feb 18 charles mathews 3.8k points
1 vote
1 answer 61 views
Problem: Hello, I am pretty much novice in this programming world. I have started learning C programming a few days back. I am taking an online course. Today we learned a few things about functions and its prototyping. I am trying to solve a ... error: too few arguments to function multiply_two_numbers' multiply_two_numbers(); I am looking forward to having a legit solution. Thanks, mate.
asked Apr 26, 2020 Gavin 15.3k points
1 vote
1 answer 439 views
Problem: Hello, kodlogers, I am writing codes in C/C++ nowadays. My code is about to add two numbers. I want to add those numbers by calling a function inside my may main function. But the program is not running for some reason. It&rsquo;s saying Error: too many arguments in function call What ... int y) { int z; z = x + y; printf ("%d\n", z); } Thanks guys for your kind help and pulling me out.
asked Apr 11, 2020 Gavin 15.3k points
0 votes
1 answer 57 views
Problem: Hi! I recently attempted an online multiple-choice question test. There was a statement that was to be marked as true or false. The statement was: A function cannot return the value of an enumeration type. I marked true but, I am confused. Can anybody here ... , then how can we return an enumeration by a function? An example program will be much helpful if this statement is false. Thanks!
asked Dec 5, 2020 Code Learner 6.2k points
0 votes
1 answer 19 views
What i am attempting to make a easy connection with XAMPP and MySQL server, however whenever I attempt to enter data or connect to the database, i obtain this error. Why this is happen and how to solve it?
asked Sep 14, 2020 Daniel Anderson 4k points
0 votes
1 answer 187 views
can someone help me why i am seeing &ldquo;PHP Fatal error: Uncaught Error: Call to undefined function mysql_query() in /Applications/MAMP/htdocs/lprapp/config.php:23 Stack trace:#0 {main} thrown in /Applications/MAMP/htdocs/lprapp/config.php on line 23&rdquo&rdquo; this error and how to resolve it.
asked Sep 14, 2020 Daniel Anderson 4k points
0 votes
1 answer 95 views