Using App Designer, reading a numeric edit field and creating a double array from the inputs?
Ältere Kommentare anzeigen
I have 3 NumericEditFields and I enter 5700 & 4750 in the first 2 (the 3rd can be blank and thus only have an array with only 2 elements). I then convert them from MegaHertz to Hertz by the following:
if isempty(app.NumericEditField_NotchCenterFreq1.Value) % check to see if the field is empty first, if so, assign an empty string
fc1 = {};
else
fc1 = app.NumericEditField_NotchCenterFreq1.Value;
fc1 = fc1 * 10e6; % Convert to Hertz
end
if isempty(app.NumericEditField_NotchCenterFreq2.Value)
fc2 = {};
else
fc2 = app.NumericEditField_NotchCenterFreq2.Value;
fc2 = fc2 * 10e6; % Convert to Hertz
end
if isempty(app.NumericEditField_NotchCenterFreq3.Value)
fc3 = {};
else
fc3 = app.NumericEditField_NotchCenterFreq3.Value;
fc3 = fc3 * 10e6; % Convert to Hertz
end
% Create an array from entered inputs
notch_fc=[fc1, fc2, fc3];
make_loadset(app, notch_fc);
The notch_fc array is
notch_fc: 1×2 cell array =
[1×4 double] [1×4 double]
But I want it to be a double array (values for example)
notch_fc: 1x2 double =
1.0e+09 *
5.7000 4.7500
How can I accomplish this? I have searched and searched and can not find the answer. Thanks in advance!
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!