ex2_18.m
来自「Programs for the book Advanced Engineeri」· M 代码 · 共 17 行
M
17 行
% EX2_18.M Compute the norm of sin(x) on the interval [0,2pi]
% Compare symbolic and numerical result
% (This script requires the Symbolic Math Toolbox)
% Numerical value; call function sinsq to compute (sin(x))^2
normsin1=sqrt(quad('sinsq',0,2*pi));
digits(5) % Define numerical format
normsin1=sym(normsin1,'d') % Numerical value
%
% Symbolic
normsq=int('sin(x)^(2)'); % Perform symbolic integration
normsq=simple(normsq) % Simplify the result
normsqn=int('sin(x)^2',0,2*pi) % Definite integral
norm2=sym(normsqn^(1/2)) % Symbolic square root
normsin=double(norm2) % Convert to a number
%
% Version 5 Use digits, sym, and double for numbers
% See help sym/double
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?