级数求解问题从输入参数改成画图。

2 views (last 30 days)
clc;
clear all;
a=1;
b=2;
q0=1/32;
D=1/pi^6;
z=0;
x=0.5;
y=1;
for m=1:2:100
for n=1:2:100
fun =16*q0*sin(m*pi*x/a)*sin(n*pi*y/b)./(pi^6*D*m*n*(m^2/a^2+n^2/b^2)^2)
z=z+fun
end
end
大佬们好这是我写的求解级数的程序。现在这个程序只能手动输入x和y的值求一个z的值,请问怎么改能改成输出x从0到1,y从0到2的图像呢?
这是原函数

Accepted Answer

华纳公司开户中心【微8785092】
仅供参考
clc;
clear all;
a=1;
b=2;
q0=1/32;
D=1/pi^6;
z=0;
Nx=10;
Ny=10;
xs=linspace(0,1,Nx);
ys=linspace(0,2,Ny);
for i=1:Nx
    for j=1:Ny
        x=xs(i);
        y=ys(j);
        for m=1:2:100
            for n=1:2:100
                fun =16*q0*sin(m*pi*x/a)*sin(n*pi*y/b)./(pi^6*D*m*n*(m^2/a^2+n^2/b^2)^2);
                z=z+fun;
            end
        end
        zs(i,j)=z;
    end
end
[xs1,ys1]=meshgrid(xs,ys);
surf(xs,ys,zs)

More Answers (0)

Categories

Find more on 循环及条件语句 in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!