Unable to recognise function from called script
I created this function in a scipted named "lab1_script.m":
t = [1, 2, 3, 4]
function y = lab1_function(t, c)
y = c*t.^2;
end
But when I try to call the script in a new script as follows:
lab1_script;
y = lab1_function(t,0.1)
The error message: unrecognisable function or variable ‘lab1_function’ appears. And I know that the function works, because when I call it within the same script it is fine. It is just trying to call it into a different script that I am having trouble with.
I am confused, what am I doing wrong? Should I be calling the script a different way for the function to be recognised?
Thanks in advance! :)I created this function in a scipted named "lab1_script.m":
t = [1, 2, 3, 4]
function y = lab1_function(t, c)
y = c*t.^2;
end
But when I try to call the script in a new script as follows:
lab1_script;
y = lab1_function(t,0.1)
The error message: unrecognisable function or variable ‘lab1_function’ appears. And I know that the function works, because when I call it within the same script it is fine. It is just trying to call it into a different script that I am having trouble with.
I am confused, what am I doing wrong? Should I be calling the script a different way for the function to be recognised?
Thanks in advance! 🙂 I created this function in a scipted named "lab1_script.m":
t = [1, 2, 3, 4]
function y = lab1_function(t, c)
y = c*t.^2;
end
But when I try to call the script in a new script as follows:
lab1_script;
y = lab1_function(t,0.1)
The error message: unrecognisable function or variable ‘lab1_function’ appears. And I know that the function works, because when I call it within the same script it is fine. It is just trying to call it into a different script that I am having trouble with.
I am confused, what am I doing wrong? Should I be calling the script a different way for the function to be recognised?
Thanks in advance! 🙂 function, calling script MATLAB Answers — New Questions
​