news 2026/4/16 16:06:38

Matlab学习记录16

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Matlab学习记录16

书籍:Matlab实用教程
因为外出,使用笔记本,没有安装matlab
电脑信息:
处理器 Intel® Core™ i7-7500U CPU @ 2.70GHz 2.90 GHz

系统类型:
系统类型 64 位操作系统, 基于 x64 的处理器
版本 Windows 10 家庭中文版
版本号 22H2

开始时使用在线工具:
https://www.cainiaojc.com/tool/octave/
1、不支持sym
2、不支持状态方程模型创建命令
3、很慢
改使用在线工具:
https://octave-online.net/
支持状态方程模型创建命令
也不支持sym
有时候连接不上。

直接安装octave
1、下载文件

2、解压
下载下来的octave-10.3.0-w64.zip,点击解压
octave-10.3.0-w64
3、找到octave-launch.exe

4、使用

与matalb差不多
使用pkg load symbolic 加载后,也可以使用sym
具体上跟matlab还是有点区别。

第3章 MATLAB 的符号计算
3.1 符号表达式的建立
3.1.1 创建符号常量

>> a=sym('sin(2)') a = (sym) sin(2)
>> a1=2*sqrt(5)+pi a1 = 7.6137 >> a2=sym('2*sqrt(5)+pi') a2 = (sym) ___ pi + 2*\/ 5 >>

3.1.2 创建符号变量和表达式

広a31 = (sym) 0 >> sym('x','real') ans = (sym) x >> sym('y','real') ans = (sym) y >> z=sym('x+iy') z = (sym) iy + x >> real(z) ans = (sym) re(iy) + re(x) >> f1=sym('a*x^2+b*x+c') f1 = (sym) 2 a*x + b*x + c >> syms a b c x >> f2=a*x^2+b*x+c f2 = (sym) 2 a*x + b*x + c >> f3=a*x^2b*x+c ^ >> f3=a*x^2+b*x+c f3 = (sym) 2 a*x + b*x + c

3.1.3 符号矩阵

>> A=sym('[a,b;c,d]') error: Python exception: SympifyError: Sympify of expression 'could not parse '[a, b;c,d]'' failed, because of exception being raised: SyntaxError: invalid syntax (<string>, line 1) occurred at line 1 of the Python code block: return S("[a,b;c,d]", rational=True) error: called from pycall_sympy__ at line 179 column 7 sym at line 489 column 9 >> syms a11 a12 a21 a22 >> A=[a11 a12;a21 a22] A = (sym 2x2 matrix) [a11 a12] [ ] [a21 a22]

3.2 符号表达式的代数运算
3.2.1 符号表达式的代数运算

>> syms a11 a12 a21 a22 >> A=[a11 a12;a21 a22] A = (sym 2x2 matrix) [a11 a12] [ ] [a21 a22] >> det(A) ans = (sym) a11*a22 - a12*a21 >> A.' ans = (sym 2x2 matrix) [a11 a21] [ ] [a12 a22] >> eig(A) ans = (sym 2x1 matrix) [ _____________________________________] [ / 2 2 ] [a11 a22 \/ a11 - 2*a11*a22 + 4*a12*a21 + a22 ] [--- + --- - ----------------------------------------] [ 2 2 2 ] [ ] [ _____________________________________] [ / 2 2 ] [a11 a22 \/ a11 - 2*a11*a22 + 4*a12*a21 + a22 ] [--- + --- + ----------------------------------------] [ 2 2 2 ]
>> f=sym('2*x^2+3*x+4') f = (sym) 2 2*x + 3*x + 4 >> g=sym('5*x+6') g = (sym) 5*x + 6 >> f*g ans = (sym) / 2 \ (5*x + 6)*\2*x + 3*x + 4/

3.2.2 符号数值任意精度控制和运算

>> a=sym('2*sqrt(5)+pi') a = (sym) ___ pi + 2*\/ 5 >> digits ans = 32 >> vpa(a) ans = (sym) 7.6137286085893726312809907207421 >> vpa(a,20) ans = (sym) 7.6137286085893726313 >> digits(15) >> vpa(a) ans = (sym) 7.61372860858937
>> a1=2/3 a1 = 0.6667 >> a2=sym(2/3) warning: passing floating-point values to sym is dangerous, see "help sym" warning: called from double_to_sym_heuristic at line 50 column 7 sym at line 384 column 11 a2 = (sym) 2/3 >> a3=vpa('2/3',32) a3 = (sym) 0.66666666666666666666666666666667 >> format long >> a1 a1 = 0.666666666666667

3.2.3 符号对象与数值对象的转换

>> a=sym('2*sqrt(5)+pi') a = (sym) ___ pi + 2*\/ 5 >> b1=double(a1) b1 = 0.666666666666667 >> a2=vpa(a=sym('2*sqrt(5)+pi'),32) a2 = (sym) 7.6137286085893726312809907207421 >> b3=eval(a) b3 = 7.613728608589373

3.3 符号表达式的操作和转换
3.3.1 符号表达式中自由变量的确定

>> f=sym('a*x^2+b*x+c') f = (sym) 2 a*x + b*x + c >> findsym(f) ans = a,b,c,x >> g=sym('sin(z)+cos(v)') g = (sym) sin(z) + cos(v) >> findsym(g,1) ans = z >>

3.3.2 符号表达式的化简

>> f=sym('x^3-6*x^2+11*x-6') f = (sym) 3 2 x - 6*x + 11*x - 6 >> g=sym('(x-1)*(x-2)*(x-3)') g = (sym) (x - 3)*(x - 2)*(x - 1) >> h=sym('x*(x*(x-6)+11)-6') h = (sym) x*(x*(x - 6) + 11) - 6 >> pretty(f) 3 2 x - 6*x + 11*x - 6 >> collect(g) error: Python exception: TypeError: collect() missing 1 required positional argume nt: 'syms' occurred at line 1 of the Python code block: return collect(*_ins) error: called from pycall_sympy__ at line 179 column 7 collect at line 59 column 3 >> collect(g,'x') ans = (sym) (x - 3)*(x - 2)*(x - 1) >> f1=sym('x^3+2*x^2*y+4*x*y+6') f1 = (sym) 3 2 x + 2*x *y + 4*x*y + 6 >> collect(f1,'y') ans = (sym) 3 / 2 \ x + y*\2*x + 4*x/ + 6 >> expand(g) ans = (sym) 3 2 x - 6*x + 11*x - 6 >> horner(f) ans = (sym) x*(x*(x - 6) + 11) - 6 >> factor(f) ans = (sym) (x - 3)*(x - 2)*(x - 1) >> y=sym('cos(x)^2+sin(x)^2') y = (sym) 2 2 sin (x) + cos (x) >> y=sym('cos(x)^2-sin(x)^2') y = (sym) 2 2 - sin (x) + cos (x) >> simplify(y) ans = (sym) cos(2*x) >> simple(y) error: 'simple' undefined near line 1, column 1

3.3.3 符号表达式的替换

>> syms a b c d x >> eig([a b;c d]) ans = (sym 2x1 matrix) [ _________________________] [ / 2 2 ] [a d \/ a - 2*a*d + 4*b*c + d ] [- + - - ----------------------------] [2 2 2 ] [ ] [ _________________________] [ / 2 2 ] [a d \/ a - 2*a*d + 4*b*c + d ] [- + - + ----------------------------] [2 2 2 ]
>> f=sym('(x+y)^2+3*(x+y)+5') f = (sym) 2 3*x + 3*y + (x + y) + 5 >> x=5 x = 5 >> f1=subs(f) f1 = (sym) 2 / 2 2 \ 2 2 \- sin (x) + cos (x) + 5/ - 3*sin (x) + 3*cos (x) + 20 >> f2=subs(f,'x+y','s') f2 = (sym) 2 s + 3*x + 3*y + 5 >> f3=subs(f,'x','z') f3 = (sym) 2 3*y + 3*z + (y + z) + 5 >> f3=subs(f,'(x+y)','s') f3 = (sym) 2 s + 3*x + 3*y + 5 >> f f = (sym) 2 3*x + 3*y + (x + y) + 5 >> f3=subs(f,'x',5) f3 = (sym) 2 3*y + (y + 5) + 20

替换时有些不对。
3.3.4 求反函数和复合函数

>> f=sym('t*e^x') f = (sym) x e *t >> g=finverse(f) error: 'finverse' undefined near line 1, column 3 The 'finverse' function belongs to the symbolic package from Octave Forge but has not yet been implemented.

3.3.5 符号表达式的转换

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/16 11:08:12

JSON Hero主题系统深度解析:打造个性化JSON可视化工作台

JSON Hero主题系统深度解析&#xff1a;打造个性化JSON可视化工作台 【免费下载链接】jsonhero-web 项目地址: https://gitcode.com/gh_mirrors/jso/jsonhero-web 作为一名开发者&#xff0c;你是否曾经被单调的JSON查看界面所困扰&#xff1f;面对海量数据时&#xff…

作者头像 李华
网站建设 2026/4/16 8:57:00

Arjun实战解析:5分钟掌握Web隐藏参数检测核心技术

Web应用安全测试中&#xff0c;Arjun参数发现工具已成为安全工程师必备的利器。这款高效的HTTP参数检测套件能够在极短时间内扫描数万个参数名称&#xff0c;帮助开发者快速发现潜在的安全漏洞。&#x1f680; 【免费下载链接】Arjun HTTP parameter discovery suite. 项目地…

作者头像 李华
网站建设 2026/4/16 13:05:05

企业级AI基础设施建设:以TensorFlow为核心的架构设计

企业级AI基础设施建设&#xff1a;以TensorFlow为核心的架构设计 在金融风控系统需要毫秒级响应、智能制造产线依赖实时缺陷检测、电商平台每秒处理数万次推荐请求的今天&#xff0c;AI早已不再是实验室里的“炫技工具”。它正作为核心生产力&#xff0c;深度嵌入企业的业务流程…

作者头像 李华
网站建设 2026/4/16 13:05:07

电梯维护预测:TensorFlow物联网数据分析

电梯维护预测&#xff1a;TensorFlow物联网数据分析 在城市高层建筑日益密集的今天&#xff0c;电梯早已不是简单的垂直交通工具——它是楼宇运行的“生命线”。一旦发生突发故障&#xff0c;不仅影响成百上千人的日常通勤&#xff0c;更可能引发严重的安全事故。传统的定期检修…

作者头像 李华
网站建设 2026/4/16 11:10:41

智能API网关的AI融合架构演进

在数字化转型浪潮中&#xff0c;企业面临AI模型碎片化管理的严峻挑战。技术团队需要同时对接OpenAI、Anthropic、百度文心一言等异构服务&#xff0c;开发人员被复杂的API协议适配所困扰&#xff0c;运维团队则在多模型流量管控中疲于奔命。智能API网关通过架构重构&#xff0c…

作者头像 李华
网站建设 2026/4/16 13:02:41

【Open-AutoGLM能做什么】:揭秘下一代自动化语言模型的5大核心能力

第一章&#xff1a;Open-AutoGLM 能干什么Open-AutoGLM 是一个开源的自动化通用语言模型&#xff08;General Language Model&#xff09;任务处理框架&#xff0c;专为简化复杂 NLP 任务流程而设计。它能够自动完成从数据预处理、模型选择、超参数调优到结果评估的完整机器学习…

作者头像 李华