How can I turn s/s to 1?

I run this code and if I click yes without change anything in the inputdlg, I receive 's/s'. How can I return this to '1' in this situation?
prompt={'Proportional Coefficient Input','Integral Coefficient Input','Derivative Coefficient Input'};
defans={'1','0','0'};
answer=inputdlg(prompt,'PID Coefficient Input',1,defans,'on');
if (~isempty(answer))
if (~isempty(answer{1}))&(~isempty(answer{2}))&(~isempty(answer{3}))&(answer{1}~='0')
syms s
x1=str2num(answer{1});
x2=str2num(answer{2});
x3=str2num(answer{3});
handles.pid(1)=x1(1);
handles.pid(2)=x2(1);
handles.pid(3)=x3(1);
handles.PID_num=[handles.pid(3),handles.pid(1),handles.pid(2)];
handles.PID_den=[1,0];
handles.PID_sys=tf(handles.PID_num,handles.PID_den);
evalc('handles.PID_sys')
end
end

 채택된 답변

Paulo Silva
Paulo Silva 2011년 6월 8일

1 개 추천

prompt={'Proportional Coefficient Input','Integral Coefficient Input','Derivative Coefficient Input'};
defans={'1','0','0'};
answer=inputdlg(prompt,'PID Coefficient Input',1,defans,'on');
if (~isempty(answer))
if (~isempty(answer{1}))&(~isempty(answer{2}))&(~isempty(answer{3}))&(answer{1}~='0')
syms s
x1=str2num(answer{1});
x2=str2num(answer{2});
x3=str2num(answer{3});
handles.pid(1)=x1(1);
handles.pid(2)=x2(1);
handles.pid(3)=x3(1);
handles.PID_num=[handles.pid(3),handles.pid(1),handles.pid(2)];
handles.PID_den=[1,0];
handles.PID_sys=tf(handles.PID_num,handles.PID_den);
[num,den] = tfdata(handles.PID_sys);
if(num{:}==den{:})
handles.PID_sys=1;
end
evalc('handles.PID_sys')
end
end

댓글 수: 7

sadel
sadel 2011년 6월 8일
I have a diplay panel which displays strings like 'Plant:' and transfer functions. I use the evalc to convert handles.PID_sys to string. After this, I use strvcat to connect the string 'Plant:' and the string of the transfer function. Then , I display them on an editbox.
sadel
sadel 2011년 6월 8일
I need the s symbol.
Paulo Silva
Paulo Silva 2011년 6월 8일
So does my code solve your problem or not?
sadel
sadel 2011년 6월 8일
Yeah, thank you!!!!
sadel
sadel 2011년 6월 8일
but now there is another problem. I cannot execute the 'c2d' function with this transfer function handles.PID_sys=1 and I think because this isn't a transfer function.
sadel
sadel 2011년 6월 8일
with this handles.PID_sys=tf([1],[1]); instead of this handles.PID_sys=1 is better!!! :)
Paulo Silva
Paulo Silva 2011년 6월 8일
even better -> handles.PID_sys=tf(1);

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 6월 8일

0 개 추천

s/s is not generally 1. In particular, that fails for 0, infinity, -infinity, and NaN.

댓글 수: 1

Paulo Silva
Paulo Silva 2011년 6월 8일
that's why the tf leaves the results the way it does, I never seen the s/s situation before, always had transfer functions with more poles than zeros, sometimes it's good to be here trying to help others, we always learn new things.

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

태그

질문:

2011년 6월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by