how to input a matrix into a function HELPPP

조회 수: 13 (최근 30일)
Aroi Mehu
Aroi Mehu 2020년 3월 6일
댓글: Aroi Mehu 2020년 3월 9일
i am confued with a question on how to create a function that accpets data maxtrix as an input. The matrix has 3 coloumns that record specfici data however i am unsure how you can input a matrix into your function.

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2020년 3월 6일
It sounds as if your new to matlab. If so welcome. Good advice then is to point you to introduction tutorials etc.
If you have your n x 3 matrix something like this:
A = [1 2 3;pi sqrt(2) exp(1)];
Then you simply send that variable to the function:
B = sin(A);
C = log(A);
and so on. Your function must have the ability to handle the matrix, but that is for the function to deal with. If you dont know how to make the function vetorized you might have to loop over the elements in the appropriate way, for that one tends to use the function size to figure out how many elements there are to loop over.
HTH

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matched Filter and Ambiguity Function에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by