フィルターのクリア

"Go to" alternative

3 ビュー (過去 30 日間)
BdS
BdS 2019 年 5 月 24 日
回答済み: Bjorn Gustavsson 2019 年 5 月 24 日
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 日
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

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by