"Go to" alternative
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
0 commentaires
Réponses (1)
Bjorn Gustavsson
le 24 Mai 2019
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
0 commentaires
Voir également
Catégories
En savoir plus sur Entering Commands dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!