koeradoera
koeradoera

Reputation: 515

matlab program to load .MAT files matlab workpace programmatically

I wrote a MATLAB code to load .MAT files

clc;
close;
val=load('C:\Users\Debian\user\cs640 machine learning\assignment5\MNIST.mat');
csvwrite('C:\Users\Debian\user\cs640 machine learning\assignment5\MNIST.csv',val);

however the file I get in return is empty file. i.e. the file in C:\Users\Debian\user\cs640 machine learning\assignment5\MNIST.csv is a blank file the computer keeps rotating rotating for a long long time but then I get a blank file. What is the error in above statements? The original file MNIST is a 30 Mb file. I am trying to implement Bayes minimum risk classifier in MATLAB I have been asked not to used any library function.

Upvotes: 0

Views: 69

Answers (1)

mattesyo
mattesyo

Reputation: 171

The output of load function is a structure and csvwrite can't save structures.

Try:

val=load('C:\Users\Debian\user\cs640 machine learning\assignment5\MNIST.mat');
val=struct2cell(val);
csvwrite('C:\Users\Debian\user\cs640 machine learning\assignment5\MNIST.csv',val);

Upvotes: 2

Related Questions