How to display a row on command window?

Hi All,
Assume I have the following:
if true
X{1}=[1 2 3];
X{2}=[2 2];
X{3}=[3 4 5];
end
I want to display this matrix in a nice form like:
X1=[1 2 3]
X2=[2 2]
X3=[3 4 5]
I am searching for a code that is slimier in the logic of the following one:
if true
for i=1:3
disp('X%d=%d',i,X{i})
end
end
Thank you very much for your help.

 採用された回答

Walter Roberson
Walter Roberson 2016 年 1 月 4 日

0 投票

for i=1:3
fprintf('X%d=[',i);
fprintf('%d ', X{i}(1:end-1));
fprintf('%d]\n', X{i}(end));
end

1 件のコメント

hadi
hadi 2016 年 1 月 6 日
Thank you very much.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2016 年 1 月 4 日

コメント済み:

2016 年 1 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by