%I want to make this code perform the same function but using a matrix M(x,y) instead of using 2 variables
%meaning I want the code to return the final values of Mx and My in a single 1x2 Matrix
function [Mx,My]=fun(P,n,p,u,U)
S= span(n,p,u,U);
Z= Bas(S,u,p,U);
Mx=0; My=0;
for k=1:p+1
Mx= Mx + Z(k) * P(1, S-(p+1)+k);
My= My + Z(k) * P(2, S-(p+1)+k);
end
end

 採用された回答

Arif Hoq
Arif Hoq 2022 年 3 月 13 日

0 投票

you can concatenate the matrix Mx and My either horizontally or vertically
% if horizontal
output=horzcat(Mx,My)
% if vertical
output=vertcat(Mx,My)

2 件のコメント

Arif Hoq
Arif Hoq 2022 年 3 月 15 日
@Mahmoud Abbas did my answer solve your problem ?
Mahmoud Abbas
Mahmoud Abbas 2022 年 3 月 15 日
Ah yes, all great!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品

リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by