MATLAB: Subscripted assignment dimension problems

MATLABsubscripted assignment structure array

Hello. I have 1×46 structure array called 'data' with numerous fields. I am particularly interested in the 'Time' field. I am trying to use subscripted assignment to calculate the time difference. Below is my code
for n = 1 : length(data)
time_dis(n) = diff(data(n).Time);
end
I know my code is wrong since there are some dimensional errors. Can anyone provide insights? Any help would be greatly appreciated. Thanks.

Best Answer

If each Time value is one single scalar then you can use this:
diff([data.Time])
You will find this useful to read through and understand: