Create an array of numbers
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
hey guys, thanks in advance
I have this matrix attached , distance_matrix. Basically is the position of a plane along a linear direction.
I have this code that finds the minimum value, which means distance to a target according to the specific position of the plane.
What I want to do , is assume that R0 is the origin of the plane movement( column 184). But we can see that plane has more positions, column 185,186,etc... I want to create an array of positions, where R0 is the center( perhaps x=0), and as the example in the matrix 185(x=1), 186(x=2),... 190(x=6). The inf numbers in the matrix doesn´t matter, but I still need that positions occupied.
But I also want that the code could assume that if R0= 190, then columns 184(x=-6), 185(x=-5),... 191(x=1),...
R0=min(distance_matrix(distance_matrix ~= 0));
0 comentarios
Respuestas (1)
dpb
el 16 de Jul. de 2022
[R0,ixR0]=min(distance_matrix(distance_matrix ~= 0));
x=(1:numel(distance_matrix))-ixR0;
2 comentarios
dpb
el 16 de Jul. de 2022
Editada: dpb
el 16 de Jul. de 2022
Not what I get with the data file you attached --
>> [R0,idx]=min(distance_matrix(distance_matrix ~= 0))
R0 =
84.9718
idx =
184
>>
Looks right to me...dunno how you got something different -- the 1 value would indicate you somehow applied to a subset of the data from that point on.
Of course, you get same result from...
>> [R0,idx]=min(distance_matrix)
R0 =
84.9718
idx =
184
>>
Ver también
Categorías
Más información sobre Logical 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!