how can i pass a vector to a function?

조회 수: 8 (최근 30일)
anu vru
anu vru 2018년 2월 8일
댓글: Ziyu Xu 2019년 10월 23일
i have a function which has 2 variables each of these variables are a vector. how do i pass vector inputs to the function???

채택된 답변

Birdman
Birdman 2018년 2월 8일
function z=f(x,y)
z=x.^2+y.^2;
end
From command line, type
x=[1;2];y=[3;4]
z=f(x,y)
and the result would be
[10;20]
  댓글 수: 1
Ziyu Xu
Ziyu Xu 2019년 10월 23일
OMG, you just saved my life!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surfaces, Volumes, and Polygons에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by