Within a separated time-series, how do I produce a loop that calculates temperature change between fortnightly water profiles?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Joshua Payne
am 5 Jun. 2017
Kommentiert: Astarag Chattopadhyay
am 13 Jun. 2017
I am currently trying to create a code that calculates the difference in temperature between several fortnightly water profiles. I have a 1x124 cell called 'ca' and in each first column cell of the first row are other closed arrays with the depth and temp readings. They are known as ca{1,1} for the first double array, ca{1,2} for the second and so on. I have the code: ca{1,1}(:,2)-ca{1,2}(:,2)
which takes the second set of temperatures from the first. How can I create a loop that will calculate the temperature change from the previous fortnightly reading for all 124 dates?
Another problem is where the profile depth maximums are not the same and I get the error - Matrix dimensions must agree. Can this be bypassed as well?
Many thanks in advance, Josh
0 Kommentare
Akzeptierte Antwort
Astarag Chattopadhyay
am 12 Jun. 2017
Hi,
You can resolve the first issue you are facing by using the following code snippet:
a=zeros(x,109); // x equals to the number of rows in temperature column of 'ca'
for i=1:123
a(:,i) = ca{1,i}(:,2)-ca{1,i+14}(:,2)
if (i+14)==123
break;
end
end
display(a);
Here, the loop starts with the first entry of the cell array 'ca' and accesses the temperature column(second column) of the array residing in that location 'ca{1,1}'. Then it finds the difference between the temperature of all the rows from that array and temperature of all the rows of the array which is 14 entries away from that location. The result of subtraction is getting stored in a (x * 109) size array where x is the number of rows in the temperature column of 'ca'. Also a check is implemented using 'if' to check if the maximum entry in 'ca' is reached or not.
The second issue what I understood is that the number of entries are different for every array. In this case you can fix a number of rows to subtract, not subtracting all the rows. If it does not affect your functionality. You can fix the row number as the number of rows of the array having the minimum among all.
2 Kommentare
Astarag Chattopadhyay
am 13 Jun. 2017
I think you got it right, interp1 would be apt to solve this issue, but you need to be careful while choosing the query points. Take into consideration all the starting and ending depth points while deciding the query points.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Environment and Settings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!