Help with storing data in a 4-D double matrix
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Voss
2022-12-20
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!