声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1180|回复: 12

[编程技巧] 【求助】一个比较复杂的积分运算

[复制链接]
发表于 2008-8-26 10:20 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
syms h h2 A A2 alfa fai d r
>> h2=h+A*cos(alfa)*sin(fai);
A2=d^2+(1-sin(fai)^2*cos(alfa)^2)*A^2-2*d*A*cos(alfa)*sqrt(1-sin(fai)^2*cos(alfa)^2);
>> f=simple((h2^2*(h2^2+A2^2+r^2))/(pi*((h2^2+A2^2+r^2+2*A2*r)^3/2)*((h2^2+A2^2+r^2-2*A2*r)^3/2)))


>>a=int(f,-pi/2,pi/2)


??? Error using ==> reshape
To RESHAPE the number of elements must not change.

Error in ==> sym.maple at 94

result = reshape(result,size(varargin{3}));


Error in ==> sym.int at 39

r = reshape(maple('map','int',f(:),x),size(f));


兄弟刚开始接触matlab,请各位先学多多帮助,谢谢!

本帖被以下淘专辑推荐:

回复
分享到:

使用道具 举报

发表于 2008-8-26 11:35 | 显示全部楼层

回复 楼主 magrog 的帖子

表达式太复杂,用数值积分
 楼主| 发表于 2008-8-26 12:27 | 显示全部楼层
我给其中的参量赋值后进行积分,好像还是报错,正在计算中,谢谢ls
 楼主| 发表于 2008-8-26 14:18 | 显示全部楼层
>> f=sqrt(1-0.25*cos(x)^2);
??? Error using ==> reshape
To RESHAPE the number of elements must not change.

Error in ==> sym.maple at 94
      result = reshape(result,size(varargin{3}));

Error in ==> sym.sqrt at 7
Y = maple('map','sqrt',X);
 楼主| 发表于 2008-8-26 14:30 | 显示全部楼层
>> clear all;
>> syms A x;
>> f=(1+A*cos(x))^2*((1+A*cos(x))^2+A^2*sin(x)^2+A*cos(x)*sqrt(1-0.25*cos(x)^2))/(((1+A*cos(x))^2+A^2*sin(x)^2+A*cos(x)*sqrt(1-0.25*cos(x)^2))^2-4*(A^2*sin(x)^2+Acos(x)*sqrt(1-0.25*cos(x)^2)))^3/2;
Warning: Could not find an exact (case-sensitive) match for 'Acos'. C:\Program Files\MATLAB704\toolbox\symbolic\@sym\acos.m is a case-insensitive match and will be used instead.  You can improve the performance of your code by using exact name matches and we therefore recommend that you update your usage accordingly.  Alternatively, you can disable this warning using warning('off','MATLAB:dispatcher:InexactMatch').
>> a=int(f,'x',-pi/2,pi/2)
Warning: Explicit integral could not be found.
> In sym.int at 58

a =

int(1/2*(1+A*cos(x))^2*((1+A*cos(x))^2+A^2*sin(x)^2+1/2*A*cos(x)*(4-cos(x)^2)^(1/2))/(((1+A*cos(x))^2+A^2*sin(x)^2+1/2*A*cos(x)*(4-cos(x)^2)^(1/2))^2-4*A^2*sin(x)^2-2*acos(x)*(4-cos(x)^2)^(1/2))^3,x = -1/2*pi .. 1/2*pi)
发表于 2008-8-26 16:55 | 显示全部楼层

回复 5楼 magrog 的帖子

用数值积分

help quad

评分

1

查看全部评分

 楼主| 发表于 2008-8-26 18:36 | 显示全部楼层
??? Error using ==> reshape
To RESHAPE the number of elements must not change.

Error in ==> sym.maple at 94
      result = reshape(result,size(varargin{3}));

Error in ==> sym.int at 51
   r = reshape(maple('map','int',f(:),[x.s '=(' a.s ')..(' b.s ')']),size(f))
我把参数赋值后积分,还是出错。不知道这个报错究竟是什么意思啊?麻烦了,能否解释一下阿?
发表于 2008-8-26 19:16 | 显示全部楼层
不明白,你连数都没算出来呢,为什么着急reshape呢?
发表于 2008-8-26 19:25 | 显示全部楼层

回复 7楼 magrog 的帖子

这个是说reshape 不能进行下去,reshape函数是一个变形矩阵的函数,
元素的 size 必须相等,
你 尝试 把 所有的 * -> .*  
/-> ./
^ -> .^
看看 是否会好
 楼主| 发表于 2008-8-26 19:37 | 显示全部楼层
不是我要用reshape ,是运行后报错显示中有这个。我也搞不懂了,这个就是函数复杂一点,怎么就积分不出来呢?
f=(h+0.5*A*cos(x))^2*((h+0.5*A*cos(x))^2+d^2+A^2*(1-0.25*cos(x)^2)+2*d*A*sqrt(1-0.25*cos(x)^2)*cos(x)+r^2)/(((h+0.5*A*cos(x))^2+d^2+A^2*(1-0.25*cos(x)^2)+2*d*A*sqrt(1-0.25*cos(x)^2)*cos(x)+r^2)^2-4*(d^2+A^2*(1-0.25*cos(x)^2)+2*d*A*sqrt(1-0.25*cos(x)^2)*cos(x))*r^2)^3/2,就是这个函数,这里面的h=0.1,A=0.05,d=0.1,r=0.05,这样就只有一个x是变量了,可是还是积分不出来,老师出现上面的报错信息。各位,这到底是怎么回事请啊?

[ 本帖最后由 magrog 于 2008-8-26 19:49 编辑 ]
发表于 2008-8-26 20:02 | 显示全部楼层

回复 10楼 magrog 的帖子

说了n篇了,用数值积分

如果不知道什么是数值积分
请查看帮助里的quadl
发表于 2008-8-26 23:01 | 显示全部楼层

回复 10楼 magrog 的帖子

试了一下,语法上没问题,就是一直在运算

你这个式子这么复杂,积不出来也正常

还是按版主说的,用数值积分吧
 楼主| 发表于 2008-8-27 15:50 | 显示全部楼层
谢谢了,数值积分是不是就是用quad命令,不用int命令啊?
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-23 05:15 , Processed in 0.068369 second(s), 20 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表