MATLAB Answers

Mathematical Process and Some measurement ın varargout

1 view (last 30 days)
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 Comment

Gözde Üstün
Gözde Üstün on 17 May 2020
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

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 17 May 2020
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 Comments

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!

Translated by