How can I generate a predefined matrix of desired dimensions from the following code?
Ältere Kommentare anzeigen
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?
Antworten (1)
Roger Stafford
am 17 Aug. 2014
Bearbeitet: Roger Stafford
am 17 Aug. 2014
1 Stimme
"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.
Kategorien
Mehr zu Correlation and Convolution finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!