Matlab 2018b 如何保存數(shù)據(jù)為excel文件
Matlab保存數(shù)據(jù)為excel的函數(shù)有很多,但是由于matlab每年都在更新,新的函數(shù)不斷涌現(xiàn),極大地方便我們運算矩陣。當我很懶沒有更新最新版本的matlab時,有些矩陣運算,就只能用相對原始地方法來做。比如2018版本不能用writecell和writematrix函數(shù)直接將數(shù)據(jù)保存excel文件。
matlab 2019及以后版本利用writematrix函數(shù)
matlab 2019 及以后的版本,可以利用writematrix() 函數(shù)直接將數(shù)據(jù)導(dǎo)出到 Excel 文件,writecell() 與 writematrix() 函數(shù)相同。 唯一的區(qū)別是 writecell() 函數(shù)的輸入是一個單元格,而 writematrix() 函數(shù)的輸入是一個矩陣。具體的步驟大家可參考鏈接: link,該鏈接講述了 writematrix() 、writetable() 和 writecell() 函數(shù)如何將數(shù)據(jù)導(dǎo)出到 excel 文件。
matlab 2018b如何保存excel?
2018版本的matlab不能用writecell和writematrix函數(shù)。因此,我結(jié)合矩陣特征,利用xlswrite函數(shù)將數(shù)據(jù)導(dǎo)出為excel文件。文章來源:http://www.zghlxwxcb.cn/news/detail-737546.html
//
test = [1 2 3;4 5 6;7 8 9;10 11 12]; % 隨機生成一個3列4行的矩陣
[m, n] = size(test);
data_cell = mat2cell(test, ones(m,1), ones(n,1)); % 將data切割成m*n的cell矩陣
title = {'Inner', 'Foreign', 'Across'};
province = {'省份';'北京';'天津';'河北';'上海'};
result = [title; data_cell]; % 將變量名稱和數(shù)值組集到result
Finalresult = [province, result]; % 將省份變量并在result矩陣中
xlswrite('E:\test.xlsx',Finalresult )
結(jié)果如下文章來源地址http://www.zghlxwxcb.cn/news/detail-737546.html
到了這里,關(guān)于Matlab如何將變量名和矩陣都保存在excel文件的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!