Clear Filters
Clear Filters

Minreal function difference between 2021a and 2021b

9 views (last 30 days)
Hello all,
i am trying to simplifiy the following transfer function
num= [0 2.326783565332 0.047642481534536 1.1320523206336 0.018636773326054 0.1736525620563 0.0018797084587909 0.0095824683611615 5.0490779499017e-05 0.0001278775430483 3.1601961291737e-07 -4.7792321851035e-08 4.7241839384478e-12 1.6520593468991e-16 -3.5261492799393e-35]
den=[1 0.16677519120767 0.49411474213873 0.072903194148789 0.077462329441744 0.0095429580373996 0.0043848511975007 0.00044880580115597 6.2185817443617e-05 5.5616071215642e-06 3.4904054871597e-08 -1.8966547971896e-09 -1.5452863299211e-11 -2.9766685962549e-15 4.4489378695401e-21]
In matlab 2021a with a tolerance of 0.005 i get:
num=[0 2.326783565332 0.0242847369269 0.29192839103876 -6.2309086400998e-20]
den = [1 0.15310693671003 0.13130203172257 0.012309590052138 9.2125282212156e-05]
While in matlab 2021b with the same tolerance i get:
num=[0 2.326783565332 0.041644199007858 1.1327911885271 0.015731663720654 0.17402398971009 0.0014368084118137 0.0096420548390914 2.6156798199821e-05 0.00013131681404352 -1.2992874796127e-08 -4.5425159381868e-13 9.6955289981649e-32]
den=[1 0.16403829533202 0.49402991560459 0.071610816843538 0.077446228810322 0.0093570713626183 0.0043874423008049 0.00044020501132602 6.2578618017865e-05 5.5506274585318e-06 4.249926757687e-08 8.1746675586304e-12 -1.2218020065151e-17]
There is quite a difference in order, but which one is the correct one? There is not any notice about changes in this function in the 2021b list of changes, or at least, i could not find anything.
Kind regards
Roberto

Accepted Answer

Paul
Paul on 17 Feb 2022
Running 2021b in the Answers facility yieds results that are very close to, but not exactlyl the same as, what you got in 2021a.
num= [0 2.326783565332 0.047642481534536 1.1320523206336 0.018636773326054 0.1736525620563 0.0018797084587909 0.0095824683611615 5.0490779499017e-05 0.0001278775430483 3.1601961291737e-07 -4.7792321851035e-08 4.7241839384478e-12 1.6520593468991e-16 -3.5261492799393e-35];
den= [1 0.16677519120767 0.49411474213873 0.072903194148789 0.077462329441744 0.0095429580373996 0.0043848511975007 0.00044880580115597 6.2185817443617e-05 5.5616071215642e-06 3.4904054871597e-08 -1.8966547971896e-09 -1.5452863299211e-11 -2.9766685962549e-15 4.4489378695401e-21];
format long e
[numr,denr] = minreal(num,den,0.005) % obsolete usage?
10 pole-zero(s) cancelled
numr = 1×5
0 2.326783565332000e+00 2.428473692692200e-02 2.919283910388171e-01 -6.230908640101220e-20
denr = 1×5
1.000000000000000e+00 1.531069367100458e-01 1.313020317225583e-01 1.230959005213707e-02 9.212528221215011e-05
I get these exact same results on my local installation (2021b, Update 2). Can you post the exact code you ran in 2021b?
  3 Comments
Paul
Paul on 21 Feb 2022
Edited: Paul on 21 Feb 2022
I get the same results as you with 2021b U2 with the "modern" approach using a tf object. I had thought that the modern and obsolete methods would yield the same answer because I assumed that the obsolete function call would just convert to tf and call the modern. Bad assumption, at least for 2021b.
However, for 2019a, the modern and obsolete methods yield the exact same answer. So something has definitely changed for the modern since 2019a (and I guess since 2021a based on your results). In 2021b, I did see that the algorthm for selecting which poles and zeros to cancel is much more complicated than in the obsolete code, which just checked if the magnitude of the difference is <= tol.
After reviewing the code, it sure looks like the minreal function for tf and zpk objects has changed since 2019a (the most recent version I have before 2021b). Not discussed in the release notes as far as I could tell.
Roberto Echeverria
Roberto Echeverria on 22 Feb 2022
Thank you very much Paul on taking the effort to confirm my theories. I think the only option to get a good answer would be to ask the official support from mathworks, as it looks to me that they forgot to fix the complete minreal function.
In my case, I will use my own approach because i need the caller function to be consistent between different versions.
Thanks again and kind regards
Roberto

Sign in to comment.

More Answers (0)

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!