当前位置: 首页 > news >正文

Python在电路课程中的应用

1 需求

   课程中有大量的计算,电路方程、复数计算,之前都是用的MATLAB online,可现在要过期了,只能更换平台。

2 工具

https://www.online-python.com/

Python3 在线工具 | 菜鸟工具 (runoob.com)

3 Sinusoid 章节

涉及到复数计算,相关函数见 cmath --- 关于复数的数学函数 — Python 3.11.5 文档

3.1 复数 1

Code

import cmath,math
a=complex(6*math.cos(30/180*math.pi),6*math.sin(30/180*math.pi)) # transfer to randian
a=cmath.rect(6,30/180*math.pi)
b=complex(5,-3)
c=complex(2,4)
d=(a+b)/c
print(f' the result is {d} ')
print(f' real  {d.real}, img  {d.imag}')print(f'in polar {abs(d)}   {cmath.phase(d)/math.pi*180} ')

 Result:

 the result is (1.0196152422706632  -2.0392304845413265j) 
 real  1.0196152422706632, img  -2.0392304845413265
in polar 2.27992899261212   -63.43494882292201 

3.2 复数2 

Code

import cmath,matha=cmath.rect(40,50/180*math.pi)
b=cmath.rect(20,-30/180*math.pi)c=cmath.sqrt(a+b)
print(f' a is {a} , b is {b}, sqrt (a+b) is {c} or  amplitude is {abs(c)} and with angle {cmath.phase(c)/math.pi*180}')

Result
 

 a is (25.711504387461574+30.64177772475912j) , b is (17.320508075688775-9.999999999999998j), sqrt (a+b) is (6.7364198203407835+1.5321029771950059j) or  amplitude is 6.908450732878534 and with angle 12.813149787630694


** Process exited - Return Code: 0 **
Press Enter to exit terminal

http://www.lryc.cn/news/142341.html

相关文章:

  • Spark SQL join的三种实现方式
  • wazuh环境配置和漏洞复现
  • 九五从零开始的运维之路(其三十六)
  • 同步和异步有什么区别,使用场景?
  • webassembly009 transformers.js 网页端侧推理
  • Android动态添加和删除控件/布局
  • maven下载不了仓库地址为https的依赖jar,配置参数忽略ssl安全检查
  • 3.Redis 单线程模型
  • 0基础学习VR全景平台篇 第90篇:智慧眼-数据统计
  • 【Go】Goland项目配置运行教程
  • Docker容器与虚拟化技术:Docker consul 实现服务注册与发现
  • 【大模型AIGC系列课程 2-2】大语言模型的“第二大脑”
  • Java基础数据结构
  • PP-TS基于启发式搜索和集成方法的时序预测模型,使预测更加准确
  • vue 04-reactive与ref的选择
  • Mysql索引+事务+存储引擎
  • 创建abp vnext项目
  • 【OpenCV实战】3.OpenCV颜色空间实战
  • 什么是回调函数(callback function)?
  • 零售再增长,直播登“C位”,美团稳稳交出成绩单
  • 什么是需求可追溯性,为什么它对产品团队很重要?
  • Window基础命令
  • Java List的扩容机制原理及应用
  • Cesium 显示经纬高
  • 专访 Hyper Oracle:可编程的 zkOracle 打造未来世界的超算
  • ThreadLocal存放当前用户
  • es入门实战
  • c++系列之指针
  • 网络安全:挑战与防护策略
  • AI 插件:未来的浏览器、前端与交互