필터 지우기
필터 지우기

Mathematical Process and Some measurement ın varargout

조회 수: 1 (최근 30일)
Gözde Üstün
Gözde Üstün 2020년 5월 17일
답변: Walter Roberson 2020년 5월 17일
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