How to import .mat file in MATLAB?

i have been trying to import a data in .mat format and after i select the file, "import wizard" window pops up which is shown below. When i click finish button but it shows a blank window. I am not able to import the .mat file. Can someone help me out? thank you in advance.

 Accepted Answer

Hi Bidyarani,
You can make use of load function to read the .mat file into MATLAB.
Below is the sample code for that:
filename = 'test.mat';
load(filename)
You can read more about the load function here: Load variables from file into workspace
Hope this helps!

3 Comments

Thank you @Kunal Kandhari. It works.
i am trying to display all the variables along with the values using code shown below.
filename = 'durer.mat';
myVars = {'d_users','cellular_users','pathloss_users','pathloss_cellular'};
S = load(filename,myVars{:})
disp(S)
Not able to display all variables.
and if i give disp command for one variable which is shown below
disp(cellular_users)
it displays all the values of the variable "cellular_users" which is 499X499 size but the thing is all the values turn out to be zero.
can you please help me out with this?
Can you please try this out:
In command window, run this command:
clear
it will clear your workspace and then run the following code:
myVars = {'d_users','cellular_users','pathloss_users','pathloss_cellular'};
load(filename,myVars{:})
disp(cellular_users)
And let me know the output
@Kunal Kandhari thanks. It works. The values of the variables are displayed correctly.

Sign in to comment.

More Answers (0)

Products

Release

R2020a

Community Treasure Hunt

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

Start Hunting!