请大神帮我编写matlab程序,求图形面积,谢谢!
发布网友
发布时间:2023-07-16 02:12
我来回答
共1个回答
热心网友
时间:2024-11-13 21:18
(1)定积分求面积
>> syms x
>> S1 = int(x^2,0,3)+int(12-x,3,12)
S1 =
99/2
(2)随机实验求面积:你上面的代码是对的啊,结果也正确
>> clear;
>> N = 1e7;
>> x = unifrnd(0,12,[1,N]);
>> y = unifrnd(0,9,[1,N]);
>> pinshu = sum(y<=x.^2&x<=3) + sum(y<=12-x&x>=3);
>> S2 = 12*9*pinshu/N
S2 =
49.5122