how to have A and A' show 3x2 column vector

1 回表示 (過去 30 日間)
carly
carly 2022 年 11 月 21 日
編集済み: carly 2022 年 11 月 21 日
so for A = [1 2 3; 4 5 6]
I want A AND A' to BOTH display:
1 4
2 5
3 6

回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 11 月 21 日
You will need to create a new class that is derived from double, and for the new class you will need to either change the vertcat() and horzcat() operators, or else the disp() or display() function; which of the methods you override depends upon whether you want the result of constructing A to be a 3 x 2 array (despite the array seemingly having been constructed as 2 x 3), or if instead you only need A to display as-if it is 3 x 2 .
  7 件のコメント
Torsten
Torsten 2022 年 11 月 21 日
編集済み: Torsten 2022 年 11 月 21 日
test([74 73 71])
ans = 3×2
6 2 6 1 5 11
test([74 73 71]')
ans = 3×2
6 2 6 1 5 11
function inch_and_feet = test(feet)
feet = feet(:);
rest_feet = mod(feet,12);
inch = (feet-rest_feet)/12;
inch_and_feet = [inch rest_feet];
end
carly
carly 2022 年 11 月 21 日
編集済み: carly 2022 年 11 月 21 日
oh my god youre amazing thank you! very helpful answer, tested out your code and found i just needed to add the (:)

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

カテゴリ

Help Center および File ExchangeConstruct and Work with Object Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by