I have a struct array in Matlab as follows:
temp_links = struct('src',{},'dest',{}, 'type', {}, 'datarate', {});
the data in temp_links
is as follows:
===============================
src dest type datarate
================================
sw_1 sw_2 sw 23
sw_1 sw_2 sw 34
sw_1 sw_2 sw 2
sw_1 sw_2 sw 3
sw_1 sw_3 sw 5
sw_1 sw_3 sw 8
sw_1 sw_3 sw 9
sw_1 sw_3 sw 3
sw_1 sw_3 sw 23
sw_1 sw_3 sw 20
sw_2 dev1 dev 30
sw_2 dev1 dev 20
...
=============================
In the above case, I would like to sum the datarates for the same src
and dest
and get a new struct array as follows:
=============================
src dest type datarate
================================
sw_1 sw_2 sw 62
sw_1 sw_3 sw 68
sw_1 dev1 dev 50
...
=============================
I am confused on how to achieve this. My thoughts were to have a switch case for each src field and then populate the dest. But I am pretty sure there is a simple way which hasn't hit me yet.
Could someone help me with this.