I have .mat file that has a size of 1374x2. How do I load this in to variable that can be used inside a function?

4 次查看(过去 30 天)
x = load ('filename');
will this make 'x' have 1374x2 values?
  3 个评论
Walter Roberson
Walter Roberson 2019-9-15
"m is equal to the number of lines in the file"
Non-comment lines. load() of a recognized text file skips lines that begin with %
Sylvester Selvanathan Pinto Stephen
Let me rephrase my question..
I have a .mat file which has 1374 rows and 2 columns which have only numeric data.
I want to load this into a variable which has the same size.
I tried this
CycleName = load('epa_city','-ascii')
Error using load
Number of columns on line 2 of ASCII file epa_city must be the same as previous lines.
How should I proceed?

请先登录,再进行评论。

回答(1 个)

Guru Mohanty
Guru Mohanty 2020-1-17
Hi, I understand you are getting error in loading a MAT file. Here is a sample code for this, in which MAT file is created using random data. You can use both load and matfile functions.
%% Create input MAT file
clear all;
val=randi(100,1374,2);
save('val.mat','val');
%% Load MAT file
clear all;
mat_var = load('val.mat');
C = mat_var.val;

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by