Pythagorean theorem with matrix
7 次查看(过去 30 天)
显示 更早的评论
Hi dear friends
I need to create a function called pita (x) that takes an array as its input argument. The matrix AB has two columns, the function must return a column vector C containing values of C that satisfy the Pythagorean theorem A^2+B^2=C^2 for the corresponding row of AB assuming that the two elements of each row of AB correspond to a pair A and B respectively, in the theorem, I have this code:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1232807/image.png)
thank you
0 个评论
采纳的回答
Voss
2022-12-15
function C = pita(AB)
A = AB(:,1);
B = AB(:,2);
C = sqrt(A.^2+B.^2); % (no transpose)
end
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!