NxN Matrix with sinusoidal element values
Mostra commenti meno recenti
I would like to create an N x N matrix with its entries to have values in a shape of a sinus curve when ploted. E.g.: let's take an arbitrary number for the first entry value of the first row. The second value is increased and so on, until the values drop again to a minimum, from which entry on they go up again and so on and so forth...until the N-th entry is reached. This is for the rows. For the column entries I would like to have the same. How can this be achieved?
Risposta accettata
Più risposte (1)
Joseph Cheng
il 29 Apr 2015
Modificato: Joseph Cheng
il 29 Apr 2015
well you'd just plot row 1 like you would a sinusoid.
x = [1:100];
y = sin(2*pi*x/6);
then repeat row 1 to make it NxN or in my example 100x100
NxN = repmat(y,100,1);
to make first entry random just choose random starting number for x
4 Commenti
Lucius
il 30 Apr 2015
Joseph Cheng
il 30 Apr 2015
Then i misread your last statement. then just create a meshplot and perform a 3d surface sine wave.
x = [1:100];
[x y] = meshgrid(x,x);
z = sin(2*pi*x/30).*sin(2*pi*y/30);
surf(z)
Lucius
il 30 Apr 2015
Star Strider
il 30 Apr 2015
@Lucius — I voted for it, so Joseph gets the same number of points.
Categorie
Scopri di più su Linear Algebra in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!