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!