Simplifying a code to one matrix
1 次查看(过去 30 天)
显示 更早的评论
%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
0 个评论
采纳的回答
Arif Hoq
2022-3-13
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!