NxN Matrix with sinusoidal element values
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Lucius
el 29 de Abr. de 2015
Comentada: Star Strider
el 30 de Abr. de 2015
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?
0 comentarios
Respuesta aceptada
Star Strider
el 30 de Abr. de 2015
I am not certain what you want. This takes the sin function on the x and y values separately:
x = linspace(0, 4*pi);
[X,Y] = meshgrid(x);
Z = sin(X) + sin(Y);
figure(1)
surf(X, Y, Z)
grid on
0 comentarios
Más respuestas (1)
Joseph Cheng
el 29 de Abr. de 2015
Editada: Joseph Cheng
el 29 de Abr. de 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 comentarios
Star Strider
el 30 de Abr. de 2015
@Lucius — I voted for it, so Joseph gets the same number of points.
Ver también
Categorías
Más información sobre Linear Algebra en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!