how to input a matrix into a function HELPPP
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Aroi Mehu
am 6 Mär. 2020
Kommentiert: Aroi Mehu
am 9 Mär. 2020
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 Kommentare
Akzeptierte Antwort
Bjorn Gustavsson
am 6 Mär. 2020
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
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!