Mathematical Process and Some measurement ın varargout

1 Ansicht (letzte 30 Tage)
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 Kommentar
Gözde Üstün
Gözde Üstün am 17 Mai 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

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 17 Mai 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;

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by