`
deepfuture
  • 浏览: 4412005 次
  • 性别: Icon_minigender_1
  • 来自: 湛江
博客专栏
073ec2a9-85b7-3ebf-a3bb-c6361e6c6f64
SQLite源码剖析
浏览量:80128
1591c4b8-62f1-3d3e-9551-25c77465da96
WIN32汇编语言学习应用...
浏览量:70342
F5390db6-59dd-338f-ba18-4e93943ff06a
神奇的perl
浏览量:103582
Dac44363-8a80-3836-99aa-f7b7780fa6e2
lucene等搜索引擎解析...
浏览量:286551
Ec49a563-4109-3c69-9c83-8f6d068ba113
深入lucene3.5源码...
浏览量:15054
9b99bfc2-19c2-3346-9100-7f8879c731ce
VB.NET并行与分布式编...
浏览量:67785
B1db2af3-06b3-35bb-ac08-59ff2d1324b4
silverlight 5...
浏览量:32292
4a56b548-ab3d-35af-a984-e0781d142c23
算法下午茶系列
浏览量:46075
社区版块
存档分类
最新评论

matlab-VQB操作MYSQL数据库及中文乱码解决

 
阅读更多

首先安装好ODBC MYSQL驱动

(64位)

http://cdn.mysql.com/Downloads/Connector-ODBC/5.2/mysql-connector-odbc-5.2.2-winx64.msi

(32位)

http://cdn.mysql.com/Downloads/Connector-ODBC/5.2/mysql-connector-odbc-5.2.2-win32.msi

然后,打开vqb

查询



 

 

插入

 



 

 

MATLAB通过ODBC操作MYSQL的中文乱码,需要在数据源中进行配置



 

查询数据(中文乱码消失了)



 

 插入中文数据

>> y2={'追求'}

y2 =

    '追求'

>>



 测试一下,查看中文数据是否正确插入



 

 

此外,关于字符编码转换的2个函数

native2unicode

Convert numeric bytes to Unicode characters

Syntax

unicodestr = native2unicode(bytes)
unicodestr = native2unicode(bytes, encoding)

Description

unicodestr = native2unicode(bytes) takes a vector containing numeric values in the range [0,255] and converts these values as a stream of 8-bit bytes to Unicode characters. The stream of bytes is assumed to be in the MATLAB default character encoding scheme. Return value unicodestr is a char vector that has the same general array shape as bytes.

unicodestr = native2unicode(bytes, encoding) does the conversion with the assumption that the byte stream is in the character encoding scheme specified by the string encoding. encoding must be the empty string ('') or a name or alias for an encoding scheme. Some examples are 'UTF-8', 'latin1', 'US-ASCII', and 'Shift_JIS'. For common names and aliases, see the Web site http://www.iana.org/assignments/character-sets. If encoding is unspecified or is the empty string (''), the MATLAB default encoding scheme is used.

    Note   If bytes is a char vector, it is returned unchanged.

Examples

This example begins with a vector of bytes in an unknown character encoding scheme. The user-written function detect_encoding determines the encoding scheme. If successful, it returns the encoding scheme name or alias as a string. If unsuccessful, it throws an error represented by an MException object, ME. The example calls native2unicode to convert the bytes to Unicode characters:

try
   enc = detect_encoding(bytes);
	   str = native2unicode(bytes, enc);
	   disp(str);
catch ME
	   rethrow(ME);
end

Note that the computer must be configured to display text in a language represented by the detected encoding scheme for the output of disp(str) to be correct.

 

================

unicode2native

Convert Unicode characters to numeric bytes

Syntax

bytes = unicode2native(unicodestr)
bytes = unicode2native(unicodestr, encoding)

Description

bytes = unicode2native(unicodestr) takes a char vector of Unicode characters, unicodestr, converts it to the MATLAB default character encoding scheme, and returns the bytes as a uint8 vector, bytes. Output vector bytes has the same general array shape as the unicodestr input. You can save the output of unicode2native to a file using the fwrite function.

bytes = unicode2native(unicodestr, encoding) converts the Unicode characters to the character encoding scheme specified by the string encoding. encoding must be the empty string ('') or a name or alias for an encoding scheme. Some examples are 'UTF-8', 'latin1', 'US-ASCII', and 'Shift_JIS'. For common names and aliases, see the Web site http://www.iana.org/assignments/character-sets. If encoding is unspecified or is the empty string (''), the MATLAB default encoding scheme is used.

Examples

This example begins with two strings containing Unicode characters. It assumes that string str1 contains text in a Western European language and string str2 contains Japanese text. The example writes both strings into the same file, using the ISO-8859-1 character encoding scheme for the first string and the Shift-JIS encoding scheme for the second string. The example uses unicode2native to convert the two strings to the appropriate encoding schemes.

fid = fopen('mixed.txt', 'w');
bytes1 = unicode2native(str1, 'ISO-8859-1');
fwrite(fid, bytes1, 'uint8');
bytes2 = unicode2native(str2, 'Shift_JIS');
fwrite(fid, bytes2, 'uint8');
fclose(fid);

 

 

 

  

 

 

报表输出

Display=>report



 

 

是否显示表头设置

display=>report generator

在这选择databaselbx.rpt

然后选择table-ans,可看到表头选项



 

 通过这种方式输出没有表头,我们修改y3变量,人为加上表头

>> y3=[{'名称'};y3]

y3 =

    '名称'
    '上大'
    '追求'

>>



 

 

逻辑型数

 



 

>> z2

z2 =

    '上大'    [1]
    '追求'    [0]

>>

 

逻辑型变量的输出形式如下:

>> insert(myconn,'myst',colnames,{'张三',logical(1)})

  • 大小: 55.3 KB
  • 大小: 51.6 KB
  • 大小: 54.5 KB
  • 大小: 61 KB
  • 大小: 57.2 KB
  • 大小: 81.4 KB
  • 大小: 42 KB
  • 大小: 98.9 KB
  • 大小: 44.5 KB
  • 大小: 55.2 KB
分享到:
评论

相关推荐

    基于MATLAB的数据库开发.pdf

    外部数据源指的是MATLAB能够连接和操作的数据库系统,如Microsoft Access、MySQL、Oracle等。开发基于外部数据源的MATLAB数据库涉及的关键技术是ODBC(开放式数据库连接)。 ODBC作为数据库应用的接口,为不同的...

    基于MATLAB的数据库开发

    总的来说,MATLAB提供了灵活且高效的方法来访问和操作数据库,无论是通过外部数据源、VQB还是结构数组,都能满足不同用户对数据库开发的需求。结合MATLAB的其他功能,如符号计算和图形处理,可以在科学研究和工程...

    Matlab数据库工具箱在数学建模中的应用.pdf

    尽管VQB易于操作,但Matlab数据库工具箱的函数具有更强大的功能,能够在VQB无法完成的领域发挥作用。数据库工具箱的函数包括连接数据库、从数据库读取数据到Matlab、将Matlab的数据输出到数据库以及关闭数据库连接等...

    7592vQB_G41M-S01_BIOS_

    BIOS MB: MSI G41M-S01 (MS-7592) BIOS TYPE: AMI (Socket 775)VERSION: 26.11 from 2012-12-10 FILE SIZE: 849 KBFILE NAME: 7592vQB.zip

    Win7家庭版怎么升级旗舰版.docx

    Win7家庭版升级旗舰版是许多用户急需解决的问题,本文档将指导用户完成升级过程,并提供了多个品牌的密钥收集。 首先,检查品牌机安装的Windows 7家庭版是否属于正宗“预装”,即具有微软正版授权且有正版标示的...

    d7sys8.2.txt(附带百度网盘密码)

    https://pan.baidu.com/s/1-pkgBdvB7VQB7IzKWHniIg

    重新编译的可使用byte[]生成二维码的zxing-core-3.4.0

    对zxing的core3.4.0新增了使用byte数组生成二维码的方法和解码方法,新增内容详细代码和使用方法参考: ...使用方法:java压缩字符串并生成二维码https://blog.csdn.net/VQB01799/article/details/126424638

    含微信二维码引擎的重编译opencv-452.jar

    重新编译的jar,集成了dll和微信扫码模块的各项配置文件,扩展了Converters类。 具体可参考:https://blog.csdn.net/VQB01799/article/details/118928239

    异构多跳无线网络中基于虚拟队列的反压调度算法

    在本文中,我们为异构多跳无线网络提出了一种基于虚拟队列的背压调度(VQB)算法。 VQB算法为节点上的每个流引入一个简单的虚拟队列以进行背压调度,其长度取决于节点的缓存大小。 在计算流量权重并做出调度决策时...

    道奇防线!-项目开发

    【压缩包子文件的文件名称列表】中,"lcd_1_ino.ino"是Arduino程序的源代码文件,扩展名".ino"是Arduino IDE所用的特定格式,它包含了游戏逻辑、LCD显示控制及按钮事件处理等代码。"dodge_schematic_qiwwK0vQB8.JPG...

    web使用js调用摄像头扫码、拍照、录像

    自己写的一个web端调用摄像头的js插件,这里是完全版,压缩版可以在(https://blog.csdn.net/VQB01799/article/details/121075074)复制。

    OpenCV4.5.2(windows for java)

    windows下编译的java版含微信二维码引擎的opencv,含opencv4.5.2+opencv_contrib4.5.2+生成的jar、dll+生成时依赖的.cache。...编译可参考:https://blog.csdn.net/VQB01799/article/details/118568089

    opencv编译工具(windows for java)

    需要注意的是,这个过程可能因OpenCV版本和你的具体需求有所不同,遇到问题时,查阅官方文档和社区论坛通常能找到解决方案。在开发过程中,不断更新和优化你的环境,以保持OpenCV的最新特性和性能。

Global site tag (gtag.js) - Google Analytics