I am trying to figure out Matlab. Tried the cmd shown in the attachment, get different response(see attachment)

댓글 수: 5

dpb
dpb 2025년 2월 20일
Include the code as text, not images...
Ken
Ken 2025년 2월 20일
이동: dpb 2025년 2월 20일
A=[-.01 .1 0 32.2;-0.4 -.8 180 0;0 -.003 -.5 0;0 0 1 0]
B=[0 -10 -2.8 0]'
P=ctrb(A,B)
P=poly(P)
A=[-.01 .1 0 32.2;-0.4 -.8 180 0;0 -.003 -.5 0;0 0 1 0]
A = 4×4
-0.0100 0.1000 0 32.2000 -0.4000 -0.8000 180.0000 0 0 -0.0030 -0.5000 0 0 0 1.0000 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
B=[0 -10 -2.8 0]'
B = 4×1
0 -10.0000 -2.8000 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
P=ctrb(A,B)
P = 4×4
0 -1.0000 -139.7500 112.9035 -10.0000 -496.0000 654.6000 -328.6400 -2.8000 1.4300 0.7730 -2.3503 0 -2.8000 1.4300 0.7730
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
P=poly(P)
P = 1×5
1.0e+05 * 0.0000 0.0049 -0.0302 -2.0054 1.5469
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
So, how do you get a different result?
A1=[-.01 .1 0 32.2;-0.4 -.8 180 0;0 -.003 -.5 0;0 0 1 0];
B1=[0 -10 -2.8 0]';
P1=ctrb(A,B);
P1=poly(P1);
all(P1==P)
ans = logical
1
Provided code doesn't produce different results for the same inputs...
Ken
Ken 2025년 2월 20일
The original post showed 2 images of the 2 separate cmds used with the resultswhich are quite different, cannot dig why they are different
Voss
Voss 2025년 2월 20일
@Ken: What are the different results/responses you see? Only one of your screenshots shows a result in the command window, which is the result of P=poly(P), a command which does not appear in the other screenshot.

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

 채택된 답변

Ken
Ken 2025년 2월 21일

0 개 추천

As mentioned earlier, I am trying to get familiar with MATLAB in aircraft controls. Focus now is Matlab. I saw a presentation with Matlab code which I posted a screenshot of. (I also posted my code to compare). Tried to duplicate the code but do not get the result shown in the Matlab window of the screenshot. Trying to figure out if something missing on my end.

댓글 수: 1

Sam Chak
Sam Chak 2025년 2월 21일
Hi @Ken,
Thank you for your response. One plausible explanation for the differing results is that your Aircraft Control Professor may have used functions from a decade-old version of MATLAB and the Control System Toolbox. Most professors I know do not frequently update their lecture slides. Therefore, if you are using more recent versions of MATLAB and the Control System Toolbox, you are likely obtaining different results.
The best approach would be to post the Control Problem Example from the lecture slides so that we can verify which result is correct or more accurate. In some rare cases, bugs can occur after MATLAB is updated.

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2025년 2월 20일

1 개 추천

A=[-.01 .1 0 32.2;-0.4 -.8 180 0;0 -.003 -.5 0;0 0 1 0]
Your screen image shows you using -32.2 rather than 32.2

댓글 수: 4

Ken
Ken 2025년 2월 20일
Thanks. The issue here is that the answers to the 2 codes posted in the 2 images of my first post (which shows the 2 images) is different. Both show -32.2 yet answer is different
dpb
dpb 2025년 2월 20일
Again, post THE EXACT CODE as text that you ran that shows the differing results; trying to do something with images is futile...and my aging eyes couldn't see the difference Walter spotted (although he's not that much younger than I... <vbg>)
If this happens, you should be able to execute the code here and have it spit out the different results.
It's virtually a certainty that the issue is something like what Walter saw, but it's not provable without the actual code/data.
Ken
Ken 2025년 2월 20일
I am trying to compare my code with one at a presentation of which I do not have the code in text. I thought ctrb gives the matrix and poly gives the polynomial of that matrix equation.
Sam Chak
Sam Chak 2025년 2월 20일
Hi Mr. @Ken
I noticed from your screenshots that your issue pertains to the controller design problem. Would you please describe the original control problem so that we can understand the full context that led to the 'cmd' issue?

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

카테고리

도움말 센터File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품

태그

질문:

Ken
2025년 2월 20일

댓글:

2025년 2월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by