0

I have a function in Matlab like this:

function func(v1)
v1
end

and I want to call it from cmd. so when I call it in cmd with command like

matlab -nodisplay -r "func("hello");"

I face an error:

Undefined function or variable 'hello'.

but I just want to have string "hello" in my function.

when I try a function which has not any argument, it works properly. but the error occurs when I want to pass argument to the function.

any help will be appreciated.

1 Answer 1

1

You want to use single quotes here:

matlab -nodisplay -r "func('hello');"
Sign up to request clarification or add additional context in comments.

4 Comments

when I want to call the function from another directory, I use command like >matlab -r "D:/matlab_function/func('hello');" and I get the error --> Error: Invalid use of operator. how should I set the command here
@ali Don't do that, use the sd flag to change directory
could you please elaborate on your explanation. did you mean cd or sd

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.