日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 人工智能 > 循环神经网络 >内容正文

循环神经网络

导出matlab程序,Matlab数据导入导出

發(fā)布時(shí)間:2025/3/21 循环神经网络 52 豆豆
生活随笔 收集整理的這篇文章主要介紹了 导出matlab程序,Matlab数据导入导出 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Matlab提供了從磁盤文件或剪貼簿轉(zhuǎn)載數(shù)據(jù)至工作區(qū)(數(shù)據(jù)導(dǎo)入)和將工作區(qū)變量存入磁盤文件(數(shù)據(jù)導(dǎo)出)的多種途徑。

最簡單的辦法是使用界面導(dǎo)入向?qū)?#xff0c;打開文件菜單中的導(dǎo)入數(shù)據(jù)而后按提示操作。

一、導(dǎo)入文本文件

load函數(shù)、dlmread函數(shù)

文本文件需要具備統(tǒng)一的行列模式,使用分隔符作為數(shù)據(jù)項(xiàng)間隔,這些分隔符包括空格、逗號(hào)、tab、分號(hào)或其它。數(shù)據(jù)文件可能附帶標(biāo)題行和行列頭標(biāo)簽。

數(shù)值數(shù)據(jù)

對(duì)于數(shù)值數(shù)據(jù)可以直接使用load函數(shù)裝載,例如my_data.txt中數(shù)據(jù)如下:

1 2 3 4 5

6 7 8 9 10

命令A(yù) = load('my_data.txt')裝載該文本文件數(shù)據(jù)。

如果數(shù)值數(shù)據(jù)使用其它分隔符,可以使用dlmread讀入,假設(shè)my_data.txt中數(shù)據(jù)如下:

7.2;8.5;6.2;6.6

5.4;9.2;8.1;7.2

命令A(yù) = dlmread('my_data.txt', ';')讀入該數(shù)據(jù)。

包含行列標(biāo)簽的數(shù)值數(shù)據(jù)

例如:

Grade1 Grade2 Grade3

78.8 55.9 45.9

99.5 66.8 78.0

89.5 77.0 56.7

fid = fopen('grades.dat', 'r');

grades = textscan(fid, '%f %f %f', 3, 'headerlines', 1);

fclose(fid);

包含字符和數(shù)值的混合數(shù)據(jù)

使用textread函數(shù)讀入。

如果是規(guī)則的用空格隔開的數(shù)據(jù),則采用data=textread(filename)格式調(diào)用,讀出的數(shù)據(jù)記錄在data矩陣中。

二、導(dǎo)出文本文件

save函數(shù)

A = [ 1 2 3 4 ; 5 6 7 8 ];

save my_data.out A –ASCII

dlmwrite函數(shù)

dlmwrite('my_data.out',A, ';')

三、MS-Excel電子表格文件

xlsinfo獲得文件信息

使用命令[type, sheets] = xlsfinfo(filename)返回文件類型type和工作表信息。如:[type, sheets] = xlsfinfo('tempdata.xls')

Xlswrite導(dǎo)出數(shù)據(jù)

d = {'Time', 'Temp'; 12 98; 13 99; 14 97}

命令xlswrite('tempdata.xls', d, 'Temperatures', 'E1')將單元格數(shù)組d的數(shù)據(jù)寫出至tempdata.xls文件,新建工作表'Temperatures',從該工作表的E1單元格開始寫入。

Xlsread讀入數(shù)據(jù)

ndata = xlsread('tempdata.xls', 'Temperatures')

[ndata, headertext] = xlsread('tempdata.xls', 'Temperatures')

底層文件輸入輸出函數(shù)

fclose?? 關(guān)閉文件

fopen?? 打開文件

fread?? 從文件中讀入二進(jìn)制數(shù)據(jù)

fwrite? 把二進(jìn)制數(shù)據(jù)寫入文件

fgetl?? 逐行從文件中讀取數(shù)據(jù)并放棄換行符

fgets?? 從文件中讀取行,保留換行符并把行作為字符串返回

fprintf? 把格式化數(shù)據(jù)寫入文件

fscanf? 從文件中讀取格式化數(shù)據(jù)

feof??? 測試文件是否結(jié)束

ferror?? 測試文件輸入輸出錯(cuò)誤信息

frewind 文件指針歸零

fseek?? 設(shè)置文件位置指針

ftell??? 獲取文件位置指針

sprintf? 把格式化數(shù)據(jù)寫入一個(gè)字符串

sscanf?? 使用格式控制讀取字符串

底層文件輸入輸出函數(shù)-->特殊函數(shù)

csvread?? 讀取逗號(hào)分隔格式的數(shù)據(jù)文件到矩陣

csvwrite?? 寫矩陣到逗號(hào)分隔格式的數(shù)據(jù)文件

dlmread?? 把一個(gè)ASCII限定文件(數(shù)據(jù)文件)讀入矩陣

dlmwrite?? 把矩陣寫入到ASCII限定文件(數(shù)據(jù)文件)

hdf?????? HDF接口??

imfinfo?? 返回圖形圖象文件的信息

imread??? 讀取圖象(到矩陣)

imwrite?? 寫入圖象

textread?? 從文本文件讀取格式化數(shù)據(jù)(important)

wk1read? 把Lotus123電子表格讀入矩陣

wk1write? 把矩陣寫入Lotus123wk1電子表格

xlsread?? 讀取excel表格

Example 1 — Reading Different Types of DataText file scan1.dat contains data in the followingform:

Sally? Level1 12.34 45 1.23e10 inf NaN Yes

Joe??? Level2 23.54 60 9e19 -inf 0.001 No

Bill?? Level3 34.90 12 2e5 10 100 No

Read each column into a variable:

fid = fopen('scan1.dat');

C = textscan(fid, '%s %s %f32 %d8 %u %f %f %s');

fclose(fid);

Note:Spaces between the conversion specifiers are shown only to make the example easier to read. They are not required.

textscan returns a 1-by-8 cell array C with the following cells:

C{1} = {'Sally'; 'Joe'; 'Bill'}????????? class cell

C{2} = {'Level1'; 'Level2'; 'Level3'}??? class cell

C{3} = [12.34; 23.54; 34.9]????????????? class single

C{4} = [45; 60; 12]????????????????????? class int8

C{5} = [4294967295; 4294967295; 200000]? class uint32

C{6} = [Inf; -Inf; 10]?????????????????? class double

C{7} = [NaN; 0.001; 100]???????????????? class double

C{8} = {'Yes'; 'No'; 'No'}?????????????? class cell

The first two elements of C{5} are the maximum values for a 32-bit unsigned integer, or intmax('uint32').

總結(jié)

以上是生活随笔為你收集整理的导出matlab程序,Matlab数据导入导出的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。