Creating a *.mat file

897 vues (au cours des 30 derniers jours)
chaos4u2
chaos4u2 le 12 Fév 2013
Commenté : nitish kumar le 28 Fév 2023
Hello, I want to create a *.mat file, for example named bathymetry. This array called bathymetry I want to be formed by 3 other arrays, for example, x, y and z. In a way, that when I charged the mat file it transforms into three files called x, y and z.
I've tried my easy way: for example: bathymetry=[x,y,z], but when I charged it, it's only 1 file called bathymetry and I want to have them separetely.
Please help me.
  2 commentaires
the cyclist
the cyclist le 12 Fév 2013
I don't know what you mean by "charge" the mat file.
Thorsten
Thorsten le 12 Fév 2013
Modifié(e) : Thorsten le 12 Fév 2013
probably "load" (German "laden" can be translated as "charge" or "load", depending on context)

Connectez-vous pour commenter.

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 12 Fév 2013
X=10
Y=20
Z=30
save bathymetry X Y Z
To load your data
load bathymetry
  3 commentaires
Annanya
Annanya le 26 Nov 2022
which file extention to use to save mat file
Saytam Maddeshiya
Saytam Maddeshiya le 14 Fév 2023
.mat

Connectez-vous pour commenter.

Plus de réponses (8)

the cyclist
the cyclist le 12 Fév 2013
Do you mean this?
% Create some variables
x = rand(3);
y = magic(3);
z = eye(3);
% Save the variable x,y,z into one *.mat file
save bathymetry.mat x y z
% Clear them out of the workspace
clear x y z
% Load them again
load bathymetry.mat
  5 commentaires
Walter Roberson
Walter Roberson le 22 Sep 2016
Machine Learning & Power Systems Ali comments
error when i save in .mat
Walter Roberson
Walter Roberson le 22 Sep 2016
Machine Learning & Power Systems Ali: we are going to need more detail than that. What is your code, and what is your exact error message?

Connectez-vous pour commenter.


matija corak
matija corak le 26 Jan 2015
Hello, I need help. I was record on my phone a sound. I want to hear that sound in matlab. How to do that? Thanks.
  1 commentaire
matija corak
matija corak le 26 Jan 2015
I already tried with load and audioread and so on. Than I tried that sound convert in .wav and he still does not recognize that file. When I put for example load pcela.wav % pcela.wav is my name of that recorded sound Error using load Unknown text on line number 1 of ASCII file pcela.wav "RIFF’_".
Am I doing something wrong? Please help me I don't have no idea anymore and I cant find anything similar on web.

Connectez-vous pour commenter.


Lobna Ragab
Lobna Ragab le 15 Jan 2016
How can I add many records to that file, I mean like
save filename X Y
X = 1,2,3,4
Y = 5,6,7,8
like table?
  1 commentaire
nitish kumar
nitish kumar le 28 Fév 2023
just use the array like
X=[1,2,3,4]
Y=[5,6 7,8]
save filename.mat X Y

Connectez-vous pour commenter.


geetu yadav
geetu yadav le 5 Avr 2016
svmStructDisease = svmtrain(diseasefeat,diseasetype); in this code how to create diseasefeat and diseasetype file?
  1 commentaire
Shivaprasad S
Shivaprasad S le 13 Avr 2016
Same problem I am also facing please give some idea how to create I don't know anything please

Connectez-vous pour commenter.


Machine Learning Enthusiast
  2 commentaires
Bjorn Gustavsson
Bjorn Gustavsson le 22 Sep 2016
That typically means that you don't have write permissions in the current directory. Move to somewhere else (cd...) and try again.
HTH
Walter Roberson
Walter Roberson le 22 Sep 2016
You are probably cd'd to a directory that is underneath the MATLAB installation. The directory that MATLAB starts executing in is not necessarily your personal MATLAB directory.

Connectez-vous pour commenter.


ramya anandan
ramya anandan le 7 Juin 2017
thank you so much Bjorn Gustavsson
  1 commentaire
Santhan S
Santhan S le 15 Jan 2018
Thanks a lot.....

Connectez-vous pour commenter.


Saravanan Nagesh
Saravanan Nagesh le 27 Mar 2018
@Machine Learning Enthusiast
Check the following code for the path of the current Matlab folder
path = pwd
use 'cd' to change it to another folder with write access.
usually, the default folder for Matlab code in most cases is" 'C:\Users\xxx'"
changing it to another drive solves this

tuncel3
tuncel3 le 2 Juil 2021
First define a file name with its location
saveFileName='datafiles\filename2.mat';
next use below code to create an empty .mat file
save(saveFileName);

Catégories

En savoir plus sur Search Path dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by