"Undefined function or variable 'x'." for input of function
2 views (last 30 days)
Show older comments
im extremely new on matlab, tried to write a code like this. my issue is when i try to see the 'y' i see "Undefined function or variable 'x'." for input of function". here is the code of mine. i can see the x but when i press for y i cant see it.
function [z]= trial(x,y)
x=1:1:7
y=x+3;
z=x.*y;
end
0 Comments
Answers (1)
Birdman
on 31 Mar 2018
Edited: Birdman
on 31 Mar 2018
Give x and y as input argument from outside as follows:
x=1:7;
y=x+3;
Then call the function from command line, do not press the green Run button the run the function:
z= trial(x,y)
Also, this tutorial should help:
2 Comments
Birdman
on 1 Apr 2018
Have you saved your function like this?
function [z]= trial(x,y)
z=x.*y;
end
After doing this, call from command as follows:
x=1:7;
y=x+3;
z= trial(x,y)
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!