Error using str2sym (line 83) Unable to convert string to symbolic expression: L 1 (C 103): BADCH: Invalid character(s).
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
Hi everyone, I am unsuccessful in converting string to symbolic expression on this code:
https://www.dropbox.com/s/xuauj97inby8o5m/IntegratedModelAnalytical.m?dl=0
What can I do?
Accepted Answer
Star Strider
on 15 Aug 2018
You are using the Unicode ‘En Dash’ (decimal 8211, hex 2013) instead of a normal hyphen (decimal 45, hex 002D) for your minus and negation signs.
You also have a ‘hanging’ negative:
Eq1 = ('n + 2*d -((e*6.24*n)/(n^2 +6.24*n + 6.24*5.68e-5))- 2*((e*6.24*5.68e-5)/(n^2 + 6.24*n + 6.24*5.68e-5))–((h*1.7e-3*n)/(n^2 + 1.7e-3*n + 1.7e-3*6.55e-8))– 2*((h*1.7e-3*6.55e-8-)/(n^2 + 1.7e-3*n + 1.7e-3*6.55e-8))- 5.3e-8/n=0');
(SCROLL RIGHT) → ↑ ← HERE
The correct version is:
Eq1 = 'n + 2*d - ((e*6.24*n)/(n^2 + 6.24*n + 6.24*5.68e-5)) - 2*((e*6.24*5.68e-5)/(n^2 + 6.24*n + 6.24*5.68e-5))-((h*1.7e-3*n)/(n^2 + 1.7e-3*n + 1.7e-3*6.55e-8)) - 2*((h*1.7e-3*6.55e-8)/(n^2 + 1.7e-3*n + 1.7e-3*6.55e-8)) - 5.3e-8/n=0';
There are other problems. I will let you solve them.
8 Comments
Thanks a lot for the comments, I will check all my minus and negative signs, and try to run the code again.
Star Strider
on 15 Aug 2018
As always, my pleasure.
When I ran your code, there were no more minus-sign or other Unicode problems, only some missing-variable errors. That may simply be a mis-spelling.
It was actually easy to solve the ‘En Dash’ problem, though. I removed the single quotes from your ‘Eq1’ string, and the MATLAB Editor highlighted each ‘En Dash’ in red.
You made it easy for me as well. Thanks.
Dursman Mchabe
on 15 Aug 2018
Edited: Dursman Mchabe
on 15 Aug 2018
The error I'm dealing with now is
"Undefined function or variable 'dEq8_char'.
Error in IntegratedModelAnalytical (line 78) dEq6, dEq7,dEq8_char{:},dEq9_char{:},dEq10_char{:},...
>> "
There is probably something wrong with my definition of dEq8_Char as
"dEq8_Char =SymArray2CharCell(dEq8);"
In the example I am following, it was defined like that, and it worked. See attached or dropbox link
https://www.dropbox.com/s/4i5mgi5wvdva7ug/SolveExample.m?dl=0
I will try to find out.
Star Strider
on 15 Aug 2018
As always, my pleasure.
If you are setting up differential-algebraic equations, the Symbolic Math Toolbox has several functions for them, and links to the appropriate numeric solvers. For an overview, see Solve DAEs Using Mass Matrix Solvers (link) and see odeFunction (link) for its documentation and links to several related functions.
The Symbolic Math Toolbox functions first appeared in R2015a.
I did DAEs method for about three months, see the attached files, it is some how more challenging. I tried both ODE15s and ODE15i. The errors were never ending.
Star Strider
on 15 Aug 2018
I have no recent experience with DAEs.
It will be best if you open a new Question describing your current problem. There are others here much more knowledgeable with respect to DAEs in MATLAB than I am.
Actually, I have been doing that for some time now, DAEs are just challenging. See the links below:
https://www.mathworks.com/matlabcentral/answers/412270-this-dae-appears-to-be-of-index-greater-than-1?s_tid=mlc_ans_email_view#comment_600007
https://www.mathworks.com/matlabcentral/answers/414912-error-using-vertcat-dimensions-of-arrays-being-concatenated-are-not-consistent?s_tid=mlc_ans_email_view#answer_332830
I only had success with IVPs and BVPs. That is the reason I am also trying DSOLVE coupled with SOLVE. It will give me analytical solutions for all the variables.
More Answers (0)
Categories
Find more on Operations on Strings in Help Center and File Exchange
Tags
See Also
on 15 Aug 2018
on 15 Aug 2018
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)