I use a structure array, which contains a field i wish to manipulate for a subset of the structure array:
snr=[node.receivedSignal]./[node.receivedNoise]temp=[node.power]nodes_to_update=snr<thresholdnewPower=temp(nodes_to_update)*2
at this point i have in my newPower array, (the power levels of the subset of nodes that i need to update). so far what i have been doing is the following:
X=num2cell(newPower)[node(nodes_to_update).power]=deal(newPower)
Since this is in a loop that repeats too many times (simulation over time), i would like to avoid using num2cell and deal. i run the profiler, and these two functions are the major slowdown on my simulation.
is there a way of assigning values into a structure array's fields from a double array, without converting into a cell and then dealing it into the structure?
Working example:
a(1).a=3a(2).a=3a(3).a=5b=[1 2]
the num2cell and deal solution:
x=num2cell(b)[a([1 3]).a]=deal(x{:})
i am looking something in the spirit of:
[a([1 3].a]=deal(b(:))
Best Answer