MATLAB: Using part of data as variables

create variableif statement

Hi, I'm trying to analyze some data exported from another program. This data file has 4 columns and a couple of hundred rows. I'm interested in the data from the 1st and the 4th column, but only for parts of it. The parts in which I am interested can be deduced from the 3th column. Example:
x y z T
0 1 0 12
1 1 0 13
4 1 0 10
5 1 0 14
6 1 .1 17
2 1 .1 11
7 1 .1 12
8 1 .5 14
So to clarify… I want to create a variable x (for z0, z0.1, z0.5 etc.) and a T variable for the same z's…
I just started with using 'if' functions and thought I could maybe use it for this. However, I don't know how. I know the next example isn't correct, but maybe it clarifies what I've got in mind…
if data(,3) == 0
save corresponding rows of column 1 to x_z00 & T_z00
end
Does anyone have an idea how I could solve this problem?

Best Answer

v=[ 0 1 0 12
1 1 0 13
4 1 0 10
5 1 0 14
6 1 .1 17
2 1 .1 11
7 1 .1 12
8 1 .5 14 ]
idx=v(:,3)==0
out=v(idx,[1 4])
Related Question