how to input a matrix into a function HELPPP
조회 수: 13 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
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개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!