フィルターのクリア

set, group in matlab

2 ビュー (過去 30 日間)
mingcheng nie
mingcheng nie 2023 年 8 月 18 日
回答済み: Ramtej 2023 年 8 月 28 日
Hi there,
I want to generate more than 10^4 times of following variables: A and B are 2D complex matrix from some distribution, C is 3D compelx matrix, where each layer of C is generated from some distribution. I am wondering if there a 'set' or 'group' function that can contain all those 10^4 times of A, B, and C? I can create 3D matrix for A and B to store 10^4 times generations, but I dont want to create a 4D matrix for matrix C...it seems inconvenient to access the datas store in them.

回答 (1 件)

Ramtej
Ramtej 2023 年 8 月 28 日
Hi mingcheng,
I understand you are trying to generate large number of instances of a variable and store them using a set or group function.
Unfortunately, in MATLAB there is no specific built-in data structure for sets and groups.
However, you can use Cell array for grouping the data to create and access the data conveniently.
Documentation for cell array: https://in.mathworks.com/help/matlab/ref/cell.html? searchHighlight=cell&s_tid=srchtitle_support_results_1_cell
% Example
numInstances = 10^4;
final_C = cell(numInstances, 1);
for itr = 1:numInstances
final_C{itr} = A; % each instance is stored in a separate cell element
end
% you can access the data for each instance of C conveniently without the need for a 4D matrix for C.
reqAns = final_C{n}(i,j,k); % to access (i,j,k)th element of nth instance.
Hope this helps!

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

製品


リリース

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by