필터 지우기
필터 지우기

Values from For Loop Iteration to save on an extra m.File

조회 수: 1 (최근 30일)
Trier87
Trier87 2012년 12월 12일
Hello, i have a .m-File with an For Loop Iteration. This .m-File calls another .m-File ( Main.m ) to solve some Variables ( for Example 'XXX' ) from the Iteration-Value PC
for PC=850:10:870
EG=1286
Main
save test.dat XXX
end
So the Program should take every new Iteration-Step into the Main.m and solve Things in it ( for Example Variable 'XXX' ) and then save it to a new .m-File ( for Example test.dat ). The Output should looks like this:
Column1(Iteration-Steps) Column2(Value of the Variable XXX form Main.m )
850 64874
860 65879
870 69766
I hope you Guys understand my Problem, big thx!

채택된 답변

TAB
TAB 2012년 12월 12일
Buff = zeros(numel(850:10:870),2);
Ctr = 1;
for PC=850:10:870
EG=1286
Main
Buff(Ctr, 1) = PC;
Buff(Ctr, 2) = XXX;
Ctr = Ctr+1;
end
save test.dat Buff;

추가 답변 (2개)

Trier87
Trier87 2012년 12월 13일
Thank You, it works but ive found now a much easier way:
data = [];
for PC = 850:10:870
step=PC
EG=1286
Main
data = [data; step, XXX];
end
save test.dat data
i have a new Question, how i can now build EG=1286:10:1306 in this For-Loop operation, so i have the PC=850:10:870 and the EG=1286:10:1306 in a Loop.
It should calculate every value of PC and EG in the Main.m
Thank you Guys!
  댓글 수: 3
Trier87
Trier87 2012년 12월 13일
Thanks for the Information. My Output should like this:
Column1 Column2 Column3
(Iteration PC=850:10:870 ) (Iteration EG=1286:10:1306) (Variable XXX)
850 1286 ...
860 1286 ...
870 1286 ...
--- --- ---
850 1296 ...
860 1296 ...
870 1296 ...
--- --- ---
850 1306 ...
860 1306 ...
870 1306 ...
This would be fantastic if this could work :-D
TAB
TAB 2012년 12월 13일
Buff = zeros(numel(850:10:870)*numel(1286:10:1306),3);
Ctr = 1;
for EG = 1286:10:1306
for PC=850:10:870
Main
Buff(Ctr, 1) = PC;
Buff(Ctr, 2) = EG;
Buff(Ctr, 3) = XXX;
Ctr = Ctr+1;
end
end
save test.dat Buff;

댓글을 달려면 로그인하십시오.


Trier87
Trier87 2012년 12월 16일
Thanks again, it works fine. I have a last Question ;) Now i want make a 3D-plot Surface of this data/values. How i can load the values of the columns from test.dat into a plot and the next question is: Must i use the Interpolation-command to create this surface. How it should looks like
  댓글 수: 1
TAB
TAB 2012년 12월 17일
Trier87, Please post your different queries in separate question so that all can see them. In this way you can get quick response for your question.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Dynamic System Models에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by