Hi
I have got the following. But it does not do what I what:
for f=1:4
for S=[3,4,7,11]
Pf1(:,S)=Pf1BM1.allocation(:,f);
Pf2(:,S)=Pf2BM1.allocation(:,f); % after this line (first iteration:f=1 and S=3), I would like that matlab goes to the second interation (f=2 and S=4) directly.
% So that the data in Pf1BM1.allocation(:,2) goes to Pf1(:,4) and Pf2(:,4). And in the third iteration (f=3 and S=7) the data in Pf1BM1.allocation(:,3) goes to Pf1(:,4) and Pf2(:,7)...
end
In VBA I just would insert the code "go to f=1:4" after the line of code Pf2(:,S)=Pf2BM1.allocation(:,f);
Do you know any other alternatives?

답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2019년 5월 24일

1 개 추천

Yeah, write your wanted input and allocation-arrays for a couple of steps. Something like:
f = [1 2 3 4];
S_from_f = {[1],[2,3],[3,7],[4,5,6]};
to_S = {[2],[3,4],[4,9],[5,6,12]};
for i1 = 1:numel(f),
for i2 = 1:numel(S_from_f{i1})
Pf1(:,to_S{i1}(i2))=Pf1BM1.allocation(:,S_from_f{i1}(i2));
etc...
end
end
You'll have to figure out how to organize your indices to get the right assignments and such...
HTH

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

BdS
2019년 5월 24일

답변:

2019년 5월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by