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

歡迎訪問 生活随笔!

生活随笔

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

循环神经网络

matlab数组存字符串,MATLAB字符串数组存储为CSV格式

發布時間:2023/12/15 循环神经网络 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 matlab数组存字符串,MATLAB字符串数组存储为CSV格式 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

直奔主題,需要保存處理圖像的文件名(string)數組。本文只用作自己的實驗記錄,侵刪。

搬運自matlab官網的代碼:https://www.mathworks.com/matlabcentral/fileexchange/7601-cell2csv?s_tid=mwa_osa_a

以下為MATLAB cell array to csv的函數實現:

function cell2csv(filename,cellArray,delimiter)

% Writes cell array content into a *.csv file.

%

% CELL2CSV(filename,cellArray,delimiter)

%

% filename = Name of the file to save. [ i.e. 'text.csv' ]

% cellarray = Name of the Cell Array where the data is in

% delimiter = seperating sign, normally:',' (it's default)

%

% by Sylvain Fiedler, KA, 2004

% modified by Rob Kohr, Rutgers, 2005 - changed to english and fixed delimiter

if nargin<3

delimiter = ',';

end

datei = fopen(filename,'w');

for z=1:size(cellArray,1)

for s=1:size(cellArray,2)

var = eval(['cellArray{z,s}']);

if size(var,1) == 0

var = '';

end

if isnumeric(var) == 1

var = num2str(var);

end

fprintf(datei,var);

if s ~= size(cellArray,2)

fprintf(datei,[delimiter]);

end

end

fprintf(datei,'\n');

end

fclose(datei);

我的調用代碼實例:

clc;

clear all;

path = 'E:\DZY\CASIA\train\2\';

fileFolder = fullfile(path);

dirOutput = dir(fullfile(fileFolder,'*.jpg'));

fileNames = {dirOutput.name};

list = string(fileNames);

n = length(fileNames);

Train_images = [];

% 創建字符串數組

Train_names = strings;

for i = 1:n

% 拼接圖片的路徑

pic_path = strcat(path, list(i));

pic_path = char(pic_path);

% fk1是自己寫的特征提取代碼,返回一個1*256的特征向量

lpq_gray = fk1(pic_path);

% 組成樣本集

Train_images(i,:) = lpq_gray;

Train_names(i,:) = list(i);

disp('processing :' + string(pic_path));

end

% 存儲文件名

save_path_data = 'E:\DZY\CASIA\ycbcr\Test0.csv';

save_path_name = 'E:\DZY\CASIA\ycbcr\Test0_name.csv';

csvwrite(save_path_data,Train_images);

%將文件名數組保存

cell2csv(save_path_name, Train_names, ',');

總結

以上是生活随笔為你收集整理的matlab数组存字符串,MATLAB字符串数组存储为CSV格式的全部內容,希望文章能夠幫你解決所遇到的問題。

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