フィルターのクリア

multidimensional array as an input of function

21 ビュー (過去 30 日間)
POLLY
POLLY 2018 年 9 月 26 日
コメント済み: Adam Danz 2018 年 9 月 26 日
Thanks for taking the time to read this. I am working with 5D matrices (in my code resultG, resultX, resultY). These matrices contain 500*500 matrices that are generated 10 times(ntrials) for each value of q and n.
My question is how should I define resultG with indices as my input for function ADMM? I have attached a part of my script.
resultX=zeros(length(n),length(q), ntrials, M, N);
resultY=zeros(length(n),length(q), ntrials, M, N);
for i=1:length(n)
for j=1:length(q)
gamma = 6/((q(j) - p)*n(i));
for k=1:1:ntrials
[X,Y,Q, iter] = ADMM(resultG(i,j,k),c, n(i), gamma,tau, opt_tol, verbose);
resultX(i,j,k, :, :)=X;
resultY(i,j,k, :, :)=Y;
  2 件のコメント
Adam Danz
Adam Danz 2018 年 9 月 26 日
"My question is how should I define resultG with indices as my input for function ADMM"
I understand that resultG is a 5D array but I don't see where that array is created. To answer your question, we'll need to understand the size and shape you expect resultG to be when going into the ADMM() function.
Would the squeeze() function be what you're looking for?
POLLY
POLLY 2018 年 9 月 26 日
編集済み: POLLY 2018 年 9 月 26 日
I create that array using the following script. G, X0, and Y0 are all MxN matrices.
resultX0 = zeros(length(n), length(q), ntrials, M, N);
resultY0 = zeros(length(n), length(q), ntrials, M, N);
resultG = zeros(length(n), length(q), ntrials, M, N);
for i=1:length(n)
for j=1:length(q)
for k=1:ntrials
[G,X0,Y0]=matrix_plantsubm(M,N,c,n(i),p,q(j));
resultX0(i,j,k,:,:)=X0;
resultY0(i,j,k,:,:)=Y0;
resultG(i,j,k,:,:)=G;
end
end
end

サインインしてコメントする。

採用された回答

Adam Danz
Adam Danz 2018 年 9 月 26 日
It's still a little unclear what size and shape you expect resultG(i,j,k) to be going into the ADMM() function but if you expect it to be a matrix, use squeeze().
[X,Y,Q, iter] = ADMM(squeeze(resultG(i,j,k,:,:)),c, n(i), gamma,tau, opt_tol, verbose)
  2 件のコメント
POLLY
POLLY 2018 年 9 月 26 日
Thank you! That works!
Adam Danz
Adam Danz 2018 年 9 月 26 日
Glad I could help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by