Error in using an element in a matrix as function input

I have an array/vector c, and I want to use it as input for my function, Viscosity like this:
function fv=Viscosity(c(1), c(2), c(3), c(4), c(5), c(21),c(24))
However, I am receiving this error:
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

 채택된 답변

Rik
Rik 2022년 10월 22일

1 개 추천

You need to pass the entire array, or treat each element as a separate variable. You can of course create the c array inside your own function.
Functions in Matlab are intended to not care about anything in the calling workspace, just the input arguments and output arguments.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2022년 10월 22일

답변:

Rik
2022년 10월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by