Different outputs with same inputs
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Hello everyone,
, in As you can see in image I'm trying to write in different forms a transfer function wich has {10+j, 10-j} poles. I obtained two different expressions, in facts in the 1st case I have {10+j, 10-j} poles, in the 2nd case I have {10, 10} poles, without no imag part.

I also tried an other case: a transfer function wich has {-10+j, -10-j} poles, but in this attempt I multiplyied the imag part with a number very close to 1, and I obtained the desiderd result: {-10+j, -10-j}. I believe that is so strange, so the question is: why I have different outputs with same inputs? It's a bug? Memory management issue? A typo?
My setup is Matlab R2020b, Windows 10 - 64 bit, Ryzen 7 4700U - 8 GB RAM
採用された回答
Cris LaPierre
2020 年 12 月 19 日
Not sure what the question is, but something is not adding up in your examples. Try clearing your workspace and running your examples again.
s=tf('s');
1/((s+10)^2 +1)
ans =
1
----------------
s^2 + 20 s + 101
Continuous-time transfer function.
% Your screenshot shows "+100" in the denominator
1/((s+i+10)*(s-i+10))
ans =
1
----------------
s^2 + 20 s + 101
Continuous-time transfer function.
% Your screenshot shows "+100" in the denominator
1/((s+i-10)*(s-i-10))
ans =
1
----------------
s^2 - 20 s + 101
Continuous-time transfer function.
Z = [];
P = [-10-1i -10+1i];
K = 1;
G = zpk(Z,P,K)
G =
1
-----------------
(s^2 + 20s + 101)
Continuous-time zero/pole/gain model.
12 件のコメント
Paolo De Ciccio
2020 年 12 月 19 日
編集済み: Paolo De Ciccio
2020 年 12 月 19 日
Thank you for your answer, my question was about I have different outputs. I also updated my question to clarify. It's a bug? Memory management issue? A typo?
Cris LaPierre
2020 年 12 月 19 日
Are the outputs I got what is expected? If so, I think you need to clear your workspace.
Paul
2020 年 12 月 19 日
Or at least clear the variable i, which may be set to a value of 0? Or change i to 1i, which would be much clearer.
Paolo De Ciccio
2020 年 12 月 19 日
編集済み: Paolo De Ciccio
2020 年 12 月 19 日
Cris: yes, you got what is expected. Paul: "i" it's a variable? Not a constant? Why do we sometimes need to clean workspace?
Paul
2020 年 12 月 19 日
Actually, i is a built in function
>> which i
built-in (C:\Program Files\MATLAB\R2019a\toolbox\matlab\elmat\i)
That built in function returns what you expect
>> i
ans =
0.0000 + 1.0000i
Unless you override by defining a same-named variable in your workspace (or other means of overriding the built-in function), which looks like might be the case based on the results you posted.
>> i=0;
>> i
i =
0
To avoid the problem and still use i as a variable, use the syntax 1i all the time
>> 1i
ans =
0.0000 + 1.0000i
Based on the result in your screen capture, it just looks like you have defined a variable i and its value is zero.
Cris LaPierre
2020 年 12 月 19 日
There is a precedence to how MATLAB decides what to do. Highest priority goes to variables you define, even if they have the same name as a built in function/constant.
Clearing a variable you defined allows MATLAB to again call the built in function.
Paolo De Ciccio
2020 年 12 月 19 日
Very nice answers, thank you!
Paolo De Ciccio
2020 年 12 月 19 日
It seems that can happens also I never defined a variable or function (or nothing else) named "i"
Cris LaPierre
2020 年 12 月 19 日
You can always find what function MATLAB is calling by using the which function.
which i
built-in (/MATLAB/toolbox/matlab/elmat/i)
i=0;
which i
i is a variable.
Paolo De Ciccio
2020 年 12 月 19 日
編集済み: Paolo De Ciccio
2020 年 12 月 19 日
So, can a new function or variable (in my case with value equal to 0, probably) does not appear in workspace? That's look like a built-in function defined during my execution
Cris LaPierre
2020 年 12 月 19 日
Technically yes. You can create custom functions that can be called by your code, but are not variables that appear in the workspace. That is likely not the case with i.
This is a computer program, though, so sometimes clearig the memory or just restarting the program can fix unexpeted behavior.
Recreating your eamples again:
s=tf('s');
i=0;
1/((s+i+10)*(s-i+10))
ans =
1
----------------
s^2 + 20 s + 100
Continuous-time transfer function.
1/(s+1.00000000001i-10)/(s-1.00000000001i-10)
ans =
1
----------------
s^2 - 20 s + 101
Continuous-time transfer function.
% Now fix the issue by clearing i
clear i
1/((s+i+10)*(s-i+10))
ans =
1
----------------
s^2 + 20 s + 101
Continuous-time transfer function.
Paolo De Ciccio
2020 年 12 月 19 日
I can accept only one answer, but I appreciated a lot all of yours
その他の回答 (0 件)
カテゴリ
ヘルプ センター および 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!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
