for loop outsite functions

2 ビュー (過去 30 日間)
TheDice
TheDice 2021 年 4 月 12 日
コメント済み: TheDice 2021 年 4 月 13 日
Hello together,
I have two functions. One triggers a measurement and the other plots the measured values. I would like to do this for multiple measurements in this order.
How can I write a for loop outside the two functions and use the loop value in the functions?
Many greetings
  1 件のコメント
Nicolas Broch
Nicolas Broch 2021 年 4 月 12 日
Hi TheDice,
could you provide a pseudo-code of what you would like to do? Because my thirst thought is that you just would like to add arguments and return values to your functions like that:
while myCondifion
[v1, v2] = fun1();
[v3, v3] = fun2(v1, v2);
end
But I guess you want to do something more complex.
Br, Nicolas

サインインしてコメントする。

回答 (1 件)

David Hill
David Hill 2021 年 4 月 13 日
Can't you just put the loop in your pushbutton function and pass the loop variable to your other functions?
function Messungstarten_ButtonPushed(app, event)
for k=1:10
MeasurementStart(app,k);
AxesValue(app,k);
end
  1 件のコメント
TheDice
TheDice 2021 年 4 月 13 日
and then you use the k as a variable in the function? Like this:
function MeasurementStart(app)
app.measurement.SampleThickness = app.Matdicke(k);
end

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by