what is wrong in this code
3 次查看(过去 30 天)
显示 更早的评论
syms t;
y=(3.7).*(10).^17;
y=3.88*(10).^16.*(t).^(1.5).*exp(-7000./t);
k=solve(y);
1 个评论
Stephen23
2017-2-12
@Angad Singh Agarwal: I formatted your code correctly by selecting the code text and then clicking the {} Code button. Next time you can do this yourself.
回答(2 个)
sjoerd
2017-2-12
编辑:sjoerd
2017-2-12
Althought it is not completely clear to me what your question/problem exactly is, I will give it a try I assumed that you want to solve the following equation for t:
3.7e17 = 3.88e16*(t)^(1.5)*exp(-7000./t)
Please note the use of 'e' for the scientific notations which makes its way shorter. Next to this I removed the dots because no need to solve this element wise (only scalar calculations).
The main problem with your code is that you first assign a value to to 'y' and then overwrite this value with the full equation. So introducing a different variable gives the following.
syms t;
result=3.7e17;
y=3.88e16*(t)^(1.5)*exp(-7000/t);
k=solve(y==result);
And this solves for t, (it will give warning that it is not symbolically solved but a numerical approximation is used).
k = 833 (approximately)
3 个评论
sjoerd
2017-2-13
I think you need to give us a little bit more information, which Matlab version do you use? I am using R2015a and it works fine. Furthermore showing a single error stack is also fine ;)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Equation Solving 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!