Using part of data as variables

3 views (last 30 days)
Tom0610
Tom0610 on 6 Jan 2016
Edited: Stephen23 on 25 Jun 2019
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?

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 6 Jan 2016
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])

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!