Passing a matrix to a function and returning

25 visualizaciones (últimos 30 días)
Unnikrishnan PC
Unnikrishnan PC el 13 de Abr. de 2014
Respondida: Image Analyst el 13 de Abr. de 2014
I wish to pass a matrix A= [ 1 2 3] and B =[2 5 7] to a function in matlab and return its sum A+B. Please help

Respuestas (1)

Image Analyst
Image Analyst el 13 de Abr. de 2014
In test.m:
function test()
A= [ 1 2 3];
B =[2 5 7]
C = AddTogether(A, B)
function c = AddTogether(a, b)
c = a + b;
Of course it's good to make it more robust with try/catch and checking that the things actually can be added together. I've just given you the bare minimum.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by