App Designer: How can I use an index to increment a Value field such as editfield1.value, editfield2.value, editfield3.value, etc.?
34 ビュー (過去 30 日間)
古いコメントを表示
I am trying to use a For-Loop index to populate my Edit Fields in my GUI as such:
NUM_OF_TIMING_REGISTERS = 16;
for i = 1:NUM_OF_TIMING_REGISTERS
if (tp{i} ~= 'FFFFFFFF')
app.EditField_Timing(i).Value = num2str(tp{i});
else
app.EditField_Timing(i).Value = tp{i};
end
end
My fields to populate (16 total) are called app.EditField_Timing1.Value, app.EditField_Timing2.Value, app.EditField_Timing3.Value, etc.
When trying the above code, I get the error:
Unrecognized method, property, or field 'EditField_Timing' for class 'TimingProtoCust'.
The original line, which is working correctly, is:
app.EditField_Timing1.Value = num2str(tp1);
How can I use the index value i to increment that property name so it will populate my 16 fields (app.EditField_Timing1.Value, app.EditField_Timing2.Value, app.EditField_Timing3.Value, etc.)?
1 件のコメント
Stephen23
約2時間 前
Another option would be to use an array of graphics handles and some basic indexing:
採用された回答
Matt J
約4時間 前
編集済み: Matt J
約4時間 前
It would be better to use a uitable for this, or at least to use numeric EditFields instead of textual EditFields.
Regardless, you can accomplish the loop as follows:
tfields="EditField_Timing"+(1:NUM_OF_TIMING_REGISTERS);
for i = 1:NUM_OF_TIMING_REGISTERS
if ~strcmp(tp{i} , 'FFFFFFFF')
app.(tfields(i)).Value = num2str(tp{i});
else
app.(tfields(i)).Value = tp{i};
end
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!