How to use a vector as input for a function?

조회 수: 11 (최근 30일)
Jeroen
Jeroen 2014년 5월 16일
편집: Randy Souza 2014년 5월 19일
I have the following m file:
function [Data] = calc_file(u)
where I would like to enter u as a vector. When I try to do this I get the following error:
>> calc_file(u)
??? Undefined function or method 'calc_file' for input
arguments of type 'double'.
How do I enter a vector as the input for a function?
  댓글 수: 1
Star Strider
Star Strider 2014년 5월 16일
You need to post the code for calc_file.

댓글을 달려면 로그인하십시오.

답변 (1개)

Henric Rydén
Henric Rydén 2014년 5월 16일
From your question, you seem to get this error only when u is a vector and not when it is a scalar?
It looks like the calc_file.m is not on your path.
  댓글 수: 2
Jeroen
Jeroen 2014년 5월 16일
I only get this error when i use a vector, with scalars it runs fine. And yes the calc_file.m is in my path.
Henric Rydén
Henric Rydén 2014년 5월 19일
OK, could you post the code in calc_file.m?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by