How can I generate a predefined matrix of desired dimensions from the following code?
Show older comments
I have the following code.
xx=sort(ceil(400*randn(1,1000)));
n=9249;
for i=1:n
A(:,i)=sin(i*xx)';
end
A=orth(A')';
figure(4)
plot(A)
title('Predefined matrix');
disp('Done.');
One dimension of matrix can be set by 'n'. But how to set another dimension?
1 Comment
Rick Rosson
on 17 Aug 2014
Answers (1)
Roger Stafford
on 17 Aug 2014
Edited: Roger Stafford
on 17 Aug 2014
1 vote
"But how to set another dimension?" Your question isn't clear to me. The number of columns in A after the operation by 'orth' is still n, but the number of rows will in general be less than 1000, and it will depend on how many rows are necessary to provide an orthogonal basis for the vector space of the rows of the original A before the 'orth' operation. This number will vary according the random choices made by 'randn'. You can't predict it ahead of time.
I would assume you wish to plot the various sine curves in the rows of A. If so, you should use plot(A'), since 'plot' makes a separate plot of each of the columns of its argument, not its rows.
I fail to see the point of your original 'sort' operation. After the 'orth' operation, the ordering in the rows of A depends on how the 'orth' function happens to be written. The effect of the sorting is presumably lost.
Categories
Find more on Correlation and Convolution in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!