Mostrar comentarios más antiguos
Hello All,
I want to create a loop. My question is, for example
1) I have a depth data, MD = 1070 1071 1074 1075 1076.1 1078 1080 1085 1087 1090
2) In other side I have image data, SRAMi which consists of 10 rows and 6 columns. its just contains 1 and 10 inside the data.
in my 1st column it has values: 1 1 10 10 10 10 10 1 1 1 in my 3rd column it has values: 1 1 1 1 10 10 10 10 1 1
as you can see the data are not similar in 1st and 3rd column. Also, MD and SRAM are two different datas which are in my workspace
I want to create a loop like when there is a change from 1 to 10 in my 1st column it should pick the values from my depth.
for example, my 1st column values shows there is a change in 3rd step, where it changes from 1 to 10 and at 7th step it changes again from 10 to 1. At this point it should pick the corresponding depth values. in this example it is 1074 and 1080.
The same way it should also pick from my 3rd column.
My aim is to find the difference in depth where there is a change (1 to 10 or 10 to 1) in 1st column and 3rd column.
for example, just to say the first change in 1st column corresponds to the depth 1074 and the 1st change in 3rd column corresponds to the depth 1076.1 so the difference will be 1076.1-1074 = 2.1m.
I am new to Matlab so if some one can help me, it will be very useful for me. It's also an emergency for me to move forward with my problem. Thanks in advance
Ela
Respuesta aceptada
Más respuestas (2)
Anathea Pepperl
el 25 de Mzo. de 2011
You can probably use the diff function to find the step changes, so that for the 1st column:
mark = diff(column1);
index = [0, logical(mark)];
You need to add a 0 to the beginning of index since diff will return an N-1 vector, given an input with N values.
depth_values = MD(index);
Once you have the depth values saved, you can use the diff function again to determine the changes in depth.
1 comentario
Fire
el 29 de Mzo. de 2011
Alexey
el 10 de Jul. de 2025
0 votos
From 1070 to 1080, go 10 rows and 6 columns.
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!