How to get matrix data from function ,anyone help me

Z=[ 1 3 4 ;5 3 1;3 3 3];
a=1;
Qa=example(a,Z);
ss=Qa(1)+Qa(2); %=====> I CAN'T get both matrix data a+Z and a*Z
%%
%%%my function building as such
function dBB=example(a,Z)
dBB(1)= Z+Z;
dBB(2)=Z+Z+Z+Z+Z;
%%%%%%

 Respuesta aceptada

James Tursa
James Tursa el 2 de Mayo de 2020
Editada: James Tursa el 2 de Mayo de 2020
Not sure what the real question is. Maybe this does what you want?
function [apZ,atZ]=example(a,Z)
apZ = a + Z;
atZ = a * Z;
end
and you would call it like this
[x,y] = example(a,Z);

2 comentarios

PRED LIU
PRED LIU el 2 de Mayo de 2020
Thank you ,James
I wnat to perform the following operations in the main program
answer = sqar ( apZ.^2 +atZ.^2)
[apZ, atZ] = example(a,Z);
answer = sqrt(apZ.^2 + atZ.^2);

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Preguntada:

el 2 de Mayo de 2020

Comentada:

el 2 de Mayo de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by