Add name for each cell in MATLAB
Show older comments
Hello friends, I created a csv file, and I want to define the first row with the name (id) and the next three cells (1 and zeros) with three names ('Absent', 'Present', 'Unknown').
How can I do it?
clc
clear
close all
cd training_data_out\
folderInfo = dir('**/*_MV.wav');
cd ..\
addpath training_data_out\
load('trainingdataa');
label=[];
totalimage=[];
for i=1:length(folderInfo)
filename = folderInfo(i).name;
[x,Fs] = audioread(filename);
x=decimate(x,4);
% label extraction
% finding different labels in text file ('Absent','Present','Unknown')
trainingdataa(:,1)=strcat(trainingdataa(:,1),'_MV.wav');
[row,column]=find(contains(trainingdataa(:,1),filename));
if trainingdataa(row,8)=='Present';
label=[label;{filename(1:end-7),1,0,0}];
elseif trainingdataa(row,8)=='Absent';
label=[label;{filename(1:end-7),0,1,0}];
else
label=[label;{filename(1:end-7),0,0,1}];
end
writecell(label,'newlabel.csv')
Accepted Answer
More Answers (0)
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!