As a newbie in MATLAB, I find myself always going for the C++-like looping instead of exploiting the matrix-based operations. I encounter another problem today.
Suppose I have two two-column tables (cell arrays), first column being user ID and second column being the corresponding values. However, they are of different sizes in the row. i.e.
Table 1
1 2.56
2 7.4
3 7.7
...
100 83.4
Table 2
1 7.1
3 1.4
4 4.4
...
76 7.2
Despite the differen row sizes, the two tables actually share some common ID. Now I wish to form a new cell array of size Nx3
, where N
is the number of the common IDs and 1st and 2nd columns are the values from table 1 and table 2, respectively. i.e.
New Table
1 2.56 7.1
3 7.7 1.4
...
Again, I can use a loop to do it, but I really wish to learn a MATLAB-ish way of doing this.