Actually the returned matrix will note necessary be square. It will have (ymax-ymin) rows and (xmax-xmin) columns
Convert two vectors (x and y) to a square matrix ?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Vingt100
el 24 de Mzo. de 2020
So here is my problem.
I have two vectors that descibe a plot (a sinusiodal function) and I want to have the discretized matrix of this plot. It means that I want to have a 1 on the curve and 0 everywhere else.
Is this possible ?
5 comentarios
Respuesta aceptada
Stephan
el 24 de Mzo. de 2020
Editada: Stephan
el 24 de Mzo. de 2020
x = 0:0.01:6.28;
y = sin(x);
M = ones(size(x,2));
x_int = 1:size(x,2);
y_int = ceil(y * size(y,2)/(abs(min(y))+abs(max(y))) +...
size(y,2)/(abs(min(y))+abs(max(y))));
y_int(y_int>size(M,2)) = y_int(y_int>size(M,2))-1;
for k = 1:size(y,2)
M(y_int(k),x_int(k)) = 0;
end
imshow(M)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Spectral Measurements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!