p47.(实习题-李荣华)用线性元求下列边值问题的数值解

  1. tic;
  2. % this method is transform from Galerkin method
  3. %also call it as finit method
  4. %is used for solving two point BVP which is the first and second term.
  5. %this code was writen by HU.D.dong in February 11th
  6. %MATLAB 7.0
  7. clear;
  8. clc;
  9. N=;
  10. h=/N;
  11. X=:h:;
  12. f=inline('(0.5*pi^2)*sin(0.5*pi.*x)');
  13. %以下是右端向量:
  14. for i=:N
  15. fun1=@(x) pi^/.*sin(pi/.*x).*(-(x-X(i))/h);
  16. fun2=@(x) pi^/.*sin(pi/.*x).*((x-X(i-))/h);
  17. f_phi(i-,)=quad(fun1,X(i),X(i+))+quad(fun2,X(i-),X(i));
  18. end
  19. funN=@(x) pi^/.*sin(pi/.*x).*(x-X(N))/h;
  20. f_phi(N)=quad(funN,X(N),X(N+));
  21. %以下是刚度矩阵:
  22. A11=quad(@(x) /h+0.25*pi^*h.*(-*x+*x.^),,);
  23. A12=quad(@(x) -/h+0.25*pi^*h.*(-x).*x,,);
  24. ANN=quad(@(x) /h+0.25*pi^*h*x.^,,);
  25. A=diag([A11*ones(,N-),ANN],)+diag(A12*ones(,N-),)+diag(A12*ones(,N-),-);
  26. Numerical_solution=A\f_phi;
  27. Numerical_solution=[;Numerical_solution];
  28. %Accurate solution on above以下是精确解
  29. %%
  30. for i=:length(X)
  31. Accurate_solution(i,)=sin((pi*X(i))/)/ - cos((pi*X(i))/)/ + exp((pi*X(i))/)*((exp(-(pi*X(i))/)*cos((pi*X(i))/))/ + (exp(-(pi*X(i))/)*sin((pi*X(i))/))/);
  32. end
  33. figure();
  34. grid on;
  35. subplot(,,);
  36. plot(X,Numerical_solution,'ro-',X,Accurate_solution,'b^:');
  37. title('Numerical solutions vs Accurate solutions');
  38. legend('Numerical_solution','Accurate_solution');
  39. subplot(,,);
  40. plot(X,Numerical_solution-Accurate_solution,'b x');
  41. legend('error_solution');
  42. title('error');
  43. toc;

Matlab-7:偏微分方程数值解法-李荣华-有限元解导数边界值的常微分(Galerkin方法)的更多相关文章

  1. MATLAB常微分方程的数值解法

    MATLAB常微分方程的数值解法 作者:凯鲁嘎吉 - 博客园http://www.cnblogs.com/kailugaji/ 一.实验目的 科学技术中常常要求解常微分方程的定解问题,所谓数值解法就是 ...

  2. 偏微分方程数值解法的MATLAB源码

    原文出处http://wenku.baidu.com/view/df412e115f0e7cd184253653.html 因为不太喜欢百度文库的格式,所以写到个人博客里面方便使用 <ifram ...

  3. C语言与MATLAB接口 编程与实例 李传军编着

    罗列一下以前自己学习C语言与MATLAB混编的笔记,顺便复习一遍. <C语言与MATLAB接口 编程与实例 李传军编着>(未看完,目前看到P106) 目录P4-8 ************ ...

  4. Euler-Maruyama discretization("欧拉-丸山"数值解法)

    欧拉法的来源 在数学和计算机科学中,欧拉方法(Euler method)命名自它的发明者莱昂哈德·欧拉,是一种一阶数值方法,用以对给定初值的常微分方程(即初值问题)求解.它是一种解决常微分方程数值积分 ...

  5. V-rep学习笔记:机器人逆运动学数值解法(The Jacobian Transpose Method)

    机器人运动学逆解的问题经常出现在动画仿真和工业机器人的轨迹规划中:We want to know how the upper joints of the hierarchy would rotate ...

  6. JS对象 JavaScript 中的所有事物都是对象,如:字符串、数值、数组、函数等,每个对象带有属性和方法。

    什么是对象 JavaScript 中的所有事物都是对象,如:字符串.数值.数组.函数等,每个对象带有属性和方法. 对象的属性:反映该对象某些特定的性质的,如:字符串的长度.图像的长宽等: 对象的方法: ...

  7. Matlab:高阶常微分三种边界条件的特殊解法(中心差分法,高精度导数边界处理)

    函数文件1: function b=F(f,x0,h,N) % b(1,1)=x0(1)-h*x0(2)-u(1); % b(2,1)=x0(2)+h*x0(1)^2-u(2)-h*f; b=zero ...

  8. Matlab:高阶常微分三种边界条件的特殊解法(隐式Euler)

    函数文件1: function b=F(f,x0,u,h) b(1,1)=x0(1)-h*x0(2)-u(1); b(2,1)=x0(2)+h*x0(1)^2-u(2)-h*f; 函数文件2: fun ...

  9. Matlab:导数边界值的有限元(Ritz)法

    tic; % this method is transform from Ritz method %is used for solving two point BVP %this code was w ...

随机推荐

  1. codeforces-3

    C Game"23" #include<iostream> using namespace std; int main() { long long n,m; long ...

  2. zw-clay字王胶泥体系列

    zw-clay字王胶泥体系列 zw-clay字王胶泥体系列,2018新版,也是在2012版本的基础上升级的. 字王胶泥体系列的idea,源自黏土动画电影的制作模式.同样,字王胶泥体系列,也非常适合于动 ...

  3. 激光三角法点云重建分享——halcon 方法

    如今视觉应用方面单纯依靠2D图像解决问题存在很多问题.稳定性差.定位不准确.还有配合机器人抓取方面只能抓高度一致的物品.其实在Halcon算法库有非常强大的三维算法.包括点云重建.激光三角法(2D相机 ...

  4. An owner of this repository has limited the ability to open a pull request to users that are collaborators on this repository.

    git 无法发起:pull request,提示:An owner of this repository has limited the ability to open a pull request ...

  5. 用python写栈

    class StackFullError(Exception): pass class StackEmptyError(Exception): pass class Stack: def __init ...

  6. JAVA EE 第二周(XML简述以及web请求的过程)

    一. 对于XML,我分别从以下几个方面来简述: 1.定义: XML是一种可扩展的标记语言,标准通用标记语言的子集,是一种用于标记电子文件使其具有结构性的标记语言. (可扩展标记语言:可扩展标记语言是一 ...

  7. Gitlab定义安全变量遇到无法转义的字符——感叹号

    我在安全变量(Secret variables)中定义了一个变量,变量值中含有特殊字符感叹号 ! . 然后我在批处理中,引用了该变量,惊奇地发现,变量值中的 ! 丢失了. 我以为是Windows CM ...

  8. centos 时钟配置

    centos 7 时钟配置: timedatectl 命令: [root@localhost ~]# timedatectl --help timedatectl [OPTIONS...] COMMA ...

  9. nodejs-使用multer实现多张图片上传,express搭建脚手架

    nodejs-使用multer实现多张图片上传,express搭建脚手架 在工作中,我们经常会看到用户有多张图片上传,并且预览展示的需求.那么在具体实现中又该怎么做呢? 本实例需要nodejs基础,本 ...

  10. spring-IoC的配置文件applicationContext.XML

    <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...