Using an existing vector in a .M file

조회 수: 12 (최근 30일)
Eduardo Chacin
Eduardo Chacin 2018년 8월 31일
댓글: Eduardo Chacin 2018년 8월 31일
Hello! I've made a simple function file and let's say I need to input a vector (50 elements) so that a function gives me the resulting vector for those elements. I have the vector in the workspace but when I try to use it as an input (instead of for example introducing the input like this [1 2 3 4 5... 50]) the vector is not recognised as a valid entry and is as if i hadn't introduced nothing. How could I solve this? Is a problem in the script? I have it as:
P_k='Introduce the 50 values';
P_k=input(P_K);
I'm new into this and I really don't know how can I solve this and hadn't found anything related
  댓글 수: 8
Stephen23
Stephen23 2018년 8월 31일
편집: Stephen23 2018년 8월 31일
function C = myFun(A,B)
C = A + B;
end
Then call the function with the required inputs:
myFun(pi,0:10)
Eduardo Chacin
Eduardo Chacin 2018년 8월 31일
@Stephen Cobeldick thank you very much

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

답변 (1개)

M
M 2018년 8월 31일
  댓글 수: 1
Eduardo Chacin
Eduardo Chacin 2018년 8월 31일
But that's for storing the input as a vector. I already have the vector and I want to use it as an input.

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

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by