Help with storing data in a 4-D double matrix
4 views (last 30 days)
Show older comments
I have a data set in the form of 8 columns. I have attached a dummy xlsx file to show the data structure.
As it can be seen, the data set includes [time, frequency, idx, node number, V1, V2, V3, V4]. I'm trying to sort and store these in a way such that I can access V3 values of a particular frequency and of a particular time. Purpose is to be able to access V3 values of a given time/frequency.
What I thought of the structure was something like this.
Re_vx = zeros(length(node_no), 2, length(time), length(frequency));
So I get a matrix in the form of (node_no, V3, time_set, freq_set).
How can I go about this? TIA!
0 Comments
Answers (1)
Voss
on 20 Dec 2022
How about storing that data set as a table:
t = readtable('new1.xlsx');
t = renamevars(t,t.Properties.VariableNames, ...
{'time','frequency','idx','node_no','V1','V2','V3','V4'})
And using logical indexing to get the values at a particular time and frequency:
my_time = t.time(15)
my_freq = t.frequency(15)
result = t(t.time == my_time & t.frequency == my_freq,:)
result.V3
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!