Mathematical Process and Some measurement ın varargout

1 次查看(过去 30 天)
I have n matrices of size d*d(first 2 index of the array) for 2 different measurement(third index of the array) with d outcomes(fourth index of the array) with varargout:
function [varargout] = trying(d)
varargout = repmat({zeros(d,d,2,d)}, 1, max(nargout,1));
U=FourierMatrix(d);
% for k=1:d
% %varargout(k,k,1,k)=1;
% varargout(:,:,2,k)=U*varargout(:,:,1,k)*U';
% end
end
However I cannot use these process on varargout I mean for each element(comes from user (vararggout) I have 2 possibilities ) like:
for k=1:d
varargout(k,k,1,k)=1;
varargout(:,:,2,k)=U*varargout(:,:,1,k)*U';
end
And moreover the second measurement of the next element is the transpose of the previous one (In this step we can use the next element is the tranpose of the first element) like that:
B(:,:,2,k)=transpose(A(:,:,2,k));
But I could not know how can I apply this process on varargout??
(If I want to write this code for 2 element, it is easy and it will be like that:)
function [item1,item2]=trying(d)
U=FourierMatrix(d);
item1=zeros(d,d,2,d);
item2=item1;
for k=1:d
item1(k,k,1,k)=1;
item1(:,:,2,k)=U*item1(:,:,1,k)*U';
item2(k,k,1,k)=1;
item2(:,:,2,k)=transpose(item1(:,:,2,k));
end
  1 个评论
Gözde Üstün
Gözde Üstün 2020-5-17
I am trying something like that :
function varargout = trying2(d)
varargout = cell(1,max(1,nargout));
varargout(:) = {zeros(d,d,2,d)};
for i=1:length(varargout)
for k=1:d
varargout(k,k,1,k)=1;
varargout(:,:,2,k)=U*varargout(:,:,1,k)*U';
end
end
end
but it is not working

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2020-5-17
varargout(k,k,1,k)=1;
varargout is always a cell vector. It will not have 4 dimensions, and you cannot directly store numeric values into it.
You can index into it such as varargout{1}(k,k,1,k) = 1;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by