How to get matrix data from function ,anyone help me

1 次查看(过去 30 天)
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;
%%%%%%

采纳的回答

James Tursa
James Tursa 2020-5-2
编辑:James Tursa 2020-5-2
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 个评论
PRED LIU
PRED LIU 2020-5-2
Thank you ,James
I wnat to perform the following operations in the main program
answer = sqar ( apZ.^2 +atZ.^2)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by