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

歡迎訪問 生活随笔!

生活随笔

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

循环神经网络

matlab to r,matlab to R import structure

發布時間:2024/9/15 循环神经网络 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 matlab to r,matlab to R import structure 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

問題

I have a structure in matlab for example

A =

in: [200x1 double]

cols: {28x1}

rows: [200x28 double]

How do I create a data frame in R which has A.cols as the columns and A.rows as the header

and A.in as the data

I am using R.Matlab package but I get stuck when I read the mat file in, how do I do this?

Thanks for your help!

回答1:

In MATLAB: convert your A to a dataset and use export() function to create a text file (in stead of .mat file). Note that your column and row names must be cells of strings but not numeric vectors.

As your A.in is a numeric matrix:

A.rows = [11,12,13,14,15]; %# numeric vector

A.cols = {'A','B','C','D','E'}; %# cell of strings

A.in = magic(5); %# numeric matrix

DS = mat2dataset(A.in,'VarNames',A.cols, 'ObsNames',cellstr(num2str(A.rows')));

export(DS,'file','A.txt')

Name for your file as you desire, e.g. 'A.txt'.

You may check the contents of your file, called "A.txt" by:

type A.txt

In R choose the folder with your 'A.txt' file and use function read.table():

A

rownames(A)

A$Observations

Explore your desired MATLAB variable in R:

head(A)

# A B C D E

# 11 17 24 1 8 15

# 12 23 5 7 14 16

# 13 4 6 13 20 22

# 14 10 12 19 21 3

# 15 11 18 25 2 9

Please note that in the example you provided, your data is in A.rows, and row names are in A.in.

來源:https://stackoverflow.com/questions/26284790/matlab-to-r-import-structure

總結

以上是生活随笔為你收集整理的matlab to r,matlab to R import structure的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。