MATLAB: Convert .csv file to .mat file

conversionconvertcsvmat

I have a csv file of 2 colunms and want to be saved as a .mat file(of desired name) with two variables of desired name(each variable of dimension 1xk)
please let me know how to write a matlab code for this.

Best Answer

T=readtable('mycsv.csv');
% ^^^^^^^^^------ your csv filename
p=T{:,1};
q=T{:,2};
save('mymat.mat','p','q')
% ^^^^^^^^^----- your resulting .mat filename