invalid use of operator

6 次查看(过去 30 天)
Dionysios
Dionysios 2023-2-6
I am trying to create an exponential function and then use the data for another script. To be more specific, I have a script file with an exponential function, but every single time I run the code I get the message: File: modfunc.m Line: 1 Column: 27
Invalid use of operator.
Here is the code:
function out = modfunc(x,a:end);
out = a(1)*exp(a(2)*x);
|x| representing time and |a| vector a with two values representing the coefficients.
  2 个评论
Walter Roberson
Walter Roberson 2023-2-6
function out = modfunc(x,a:end)
What is your intention for the a:end clause ?
Dionysios
Dionysios 2023-2-6
Thank you, I should have removed :end. Now it works perfectly.

请先登录,再进行评论。

回答(2 个)

John D'Errico
John D'Errico 2023-2-6
Looks great. Except, what you have written is not valid MATLAB syntax.
Why do you think you needed to include the :end in there? a is a vector of length 2. No problem.
function out = modfunc(x,a);
out = a(1)*exp(a(2)*x);

Sulaymon Eshkabilov
The corrected syntax of this is:
function out = modfunc(x,a);
out = a(1)*exp(a(2)*x);

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by