Unable to use Poly function on matlab 2020b, and 2019b

6 次查看(过去 30 天)
My current issue is that I'm unable to use a couple of functions and I was troubleshooting the problem but no luck.
I have this snip from a code which doesn't work on only my end
numerator=1;
denominator=poly([-2 -4 -6 -8]);
G=tf(numerator,denominator);
---
The error message
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct
matrices, use brackets instead of parentheses.
Now, I have friends who have the same version of matlab as me and 2019b and I copy and paste send them the code and it runs fine on their end. I ended up reinstalling matlab 2019b with all the student toolboxes but that didn't help. Anyone know how to fix this? I had purchased the 2019 matlab and then I had also linked my school's license for when we went online due to covid and was available for us that way too.

回答(1 个)

Shubham Khatri
Shubham Khatri 2021-5-10
Hello,
Usually, MATLAB points to the specific position that is causing the syntax error as:
denominator=poly[-2 -4 -6 -8]); ↑ Error: Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
Can you please share the exact error message when the code does not run. so that we can locate, if the source codes for "poly" or "tf" have somehow been altered, we still get the message that points us to the line where the error is.
Hope it helps

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by