how to type sin^2(x) instead of sin(x)^2
52 views (last 30 days)
Show older comments
i cant type it it always gives error. I just want sin^2(x), but i can only type in sin(x)^2
i left a pic to the type of thing that i want to get.
5 Comments
John D'Errico
on 10 Dec 2020
Edited: John D'Errico
on 10 Dec 2020
Think of it as if you went to a foreign country, and wanted to talk to people using your own adulterated version of their language. Would you be surprised if many people were insulted? If you want to be understood, you will need to learn the language, even if you like your personal version better.
While sin^2 may be correct in your view, it is not valid MATLAB syntax, and it matters not how badly you want that to be true.
Answers (1)
John D'Errico
on 10 Dec 2020
That is just MATLAB syntax. You can want it to be different, but you really have no choices. When you use a language, you need to learn the syntax. Sorry, but you do.
Is it a syntax that some people use? Well, yes. But computers are not very flexible. This is not even something that I would see you being able to write some special class of your own. (That is one fix that works for a lot of problems, if you are willing to do the work.) But in this case, I don't even see it as something you could easily implement, even if you were willing to make the effort, because this gets into the basic parsing rules of MATLAB.
You could theoretically pose an enhancement request. You would need to send that to The MathWorks directly. I'd not get my hopes up high though of it happening any time soon, because this would involve a fairly significant change in how MATLAB would need to parse code.
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!