フィルターのクリア

How do i convert a sentence of string numbers into multiple doubles

4 ビュー (過去 30 日間)
Janno Rhey Don
Janno Rhey Don 2020 年 7 月 20 日
コメント済み: Janno Rhey Don 2020 年 7 月 23 日
Hello guys! Im kinda new with using the GUI for MATLAB, and I have a school project which needs a GUI that accepts transfer functions and plot their unit step plot (impulse(cs,rs)), to verify their Kp, Kv, Ka.
I'm trying to a GUI that accepts a transfer function but i dont know how to implement it. I decided that i'll use an editbox to input the numeric values for the transfer function's num and denom, using this:
x = str2double(get(handles.edit1, 'string'));
y = str2double(get(handles.edit2, 'string'));
set(handles.text2, 'string', x)
sys1=tf([x],poly([y]))
so far it accepts only one number in the numerator and denominator i wanted to be able to input something like this:
>> sys1=tf([20 20],poly([-4 -3]))
sys1 =
20 s + 20
--------------
s^2 + 7 s + 12
  1 件のコメント
Janno Rhey Don
Janno Rhey Don 2020 年 7 月 23 日
update i tried using str2num used in at the numerator of the tf() and it worked but it somehow doesnt work on the denominator, any ideas on why this is the case?
FP = str2num(get(handles.edit1, 'string'));
ca = str2num(get(handles.edit3, 'string'));
sys1=tf(FP,poly(ca))
sys1a=feedback(sys1, 1, -1);
rs=tf([1], [1 0]);
cs= rs*sys1a;
axes(handles.axes1);
impulse(cs,rs);
grid on
ERROR message:
Error using str2num (line 35)
Input must be a character vector or string scalar.
Error in testing>pushbutton1_Callback (line 132)
ca = str2num(get(handles.edit3, 'string'));
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in testing (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)testing('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.

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

採用された回答

Walter Roberson
Walter Roberson 2020 年 7 月 23 日
You configured edit3 to have Max that is greater than 1, and the user entered more than one line.
The user did not just enter spaces between the numbers: they would have had to press return between numbers for this to have happened... and it cannot happen if Max is at its default 1.
(Exception: if you initialized edit3 String property to multiple cell entries, then if Max was set to 1, then it would have given a warning and refused to render the box for the control, but getting its String property would have returned the multiple cell entries. This is the exception to the rule that Max must have been greater than 1 and the user entered multiple lines -- the case where you yourself initialized the control that way.)
  1 件のコメント
Janno Rhey Don
Janno Rhey Don 2020 年 7 月 23 日
Hello thank you for the reply, i have now fixed the numerator denominator part and can know plot the whole function my problem at the moment is getting the limit s->0, of the transfer function that i defined using:
sysa=tf [ 20 20], poly[-4 -3]));
i tried using limit(sysa); but it said "Undefined function 'limit' for input arguments of
type 'tf'."

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by