How to get matrix data from function ,anyone help me

3 ビュー (過去 30 日間)
PRED LIU
PRED LIU 2020 年 5 月 2 日
コメント済み: Walter Roberson 2020 年 5 月 2 日
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)
Walter Roberson
Walter Roberson 2020 年 5 月 2 日
[apZ, atZ] = example(a,Z);
answer = sqrt(apZ.^2 + atZ.^2);

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by