matlab的字符运算的问题。
이전 댓글 표시
由于所求函数f的表达式里含有很多字符常量sr se pr k theta pe w,只有pr和sr是未知的,现在求f最大值时的pr和sr。我觉得手算比较麻烦,而且容易出错,所以想借用matlab的字符运算功能,但是下面的代码运行出的结果是
>> lianxi
y1 =
- sr - ((k - theta)/theta + 1)*(w - (pe - se - k*sr + sr*theta + k*se*theta)/theta) - ((k - theta)*(sr - (pe - se - k*sr + sr*theta + k*se*theta)/theta + k*se + 1))/theta
Warning: Explicit solution could not be found.
> In solve at 169
In lianxi at 6
y1_sr =
[ empty sym ]
我的代码:
syms sr se pr k theta pe w;
pr=(theta*sr-k*sr-se+k*theta*se+pe)/theta;
qr=1+sr+k*se-pr;
f=(pr-w)*qr-sr^2/2;
f
y1=diff(f,sr)
y1_sr=solve('y1=0','sr')
我的问题:1我代码的错误在哪儿呢?2听人说含有字符函数求解里用matlab不太方便,还想问问各位求解这类的问题用matlab合适吗?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 编程에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!