求大神帮我编写一下matlab代码 matlab编写卷积函数

8266℃ DELIA

求大神帮我编写一下matlab代码matlab编写卷积函数

写出matlab代码?

题目不是很清楚,就挑清楚地做一下。

% By lyqmath

% DLUT School of Mathematical Sciences

% BLOG: blog.csdn/lyqmath

clc; close all; clear all;

syms x

y = sin(x)/x;

diff(y, x)

syms x

eq = x^2*sin(x);

int(eq, x)

t = linspace(-4*pi, 4*pi);

y = sin(t);

figure; plot(t, y);

结果:

 

ans =

 

cos(x)/x - sin(x)/x^2

 

 

ans =

 

2*x*sin(x) - cos(x)*(x^2 - 2)

 

>>

>>

求各位大神帮忙编一下matlab程序

f = @(x) sum(x); % 目标函数

A=[-6,-4,-4,-2,-1,-1,0;0,-1,0,-2,-1,0,-1;0,0,-1,0,-1,-2,0]; % 线性约束

B = [-100,-100,-100];

lb=zeros(1,7); % 下限为0

ub=inf*ones(1,7); % 上限为无穷大

op = optimset('Algorithm','interior-point'); % 约束算法

x0 = 10*ones(1,7); % 假设初始值为每个变量都是10

[x,fval] = fmincon(f,x0,A,B,[],[],lb,ub,[],op) % 约束极值

Local minimum found that satisfies the constraints.

Optimization completed because the objective function is non-decreasing in 

feasible directions, to within the default value of the function tolerance,

and constraints were satisfied to within the default value of the constraint tolerance.

x =

    0.0000    0.0000    0.0000   33.3211   33.3579   33.3211    0.0000

fval =

  100.0000

求高手帮忙编MATLAB程序

在Matlab下输入:edit,然后将下面两行百分号之间的内容,复制进去,保存

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function f=f31(x)

f=1./[(x-2).^2+0.1]+1./[(x-3).^4+0.01];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

返回matlab主界面

输入:

temp=[1,2,3;4,5,6];

f=f31(temp) %验证x是矩阵输入,程序能跑

x=0:0.01:4;

f=f31(x);

plot(x,f)

2题

在Matlab下输入:edit,然后将下面两行百分号之间的内容,复制进去,保存

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function dydx=zh_lankesterljy(x,y)

dydx=x.^2./y-x.*cos(y);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

在Matlab下面输入:

t_end=5;

y0=[1];

[x,y]=ode45('zh_lankesterljy',[0,t_end],y0);

plot(x,y);

xlabel('x');

ylabel('y');

求MATLAB代码

clear;clc

[x,y]=meshgrid(linspace(-5,5));

for k=linspace(-4,4)

    mesh(x,y,x.^2+y.^2+k*x.*y);

    legend(sprintf('k=%.2f',k),'location','south');

    zlim([-100,100]);

    pause(0.01)

endk>2或k<-2时为马鞍面;k=±2时为柱面;-2