A weird blank matrix....

3 ビュー (過去 30 日間)
Emma Humphrey
Emma Humphrey 2018 年 10 月 18 日
回答済み: Walter Roberson 2018 年 10 月 18 日
Hello all, I am new to matlab and trying to figure out the following code. As you can see I have commented out the line in question and marked it. Apart from preallocation, I fail to see the point in the code Xu as it doesn't appear to affect the final result.
Many thanks
hold on
title('Plot of uniform random numbers')
Xu = [];
for i=1:nn
x = rand(mm,2) %create a random 2 column matrix of numbers
%Xu = [Xu;x] %what does this do?
plot(x(:,1),x(:,2),'*');
end

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 10 月 18 日
It does not affect the final plotted result. It does, however, keep a record of all of the x values that were generated, in case you want them later.

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by