How to creating MAT file
2 views (last 30 days)
Show older comments
Ivan Dwi Putra
on 19 Oct 2020
Commented: Ivan Dwi Putra
on 19 Oct 2020
This is my parameter
% Parameter Massa
m1 = 8095; % massa train set 1 dalam kg
m2 = 8500; % massa train set 2 dalam kg
m3 = 8457; % massa train set 3 dalam kg
% Parameter Gaya
f1 = 205.*10^3; % Gaya train set 1 dalam N
f2 = 302.*10^3; % Gaya train set 2 dalam N
f3 = 302.*10^3; % Gaya train set 3 dalam N
% Parameter Resistansi
c_0_1 = 0.01176;
c_1_1 = 0.00077616;
c_2_1 = 4.48 ;
c_0_2 = 0.01176 ;
c_1_2 = 0.00077616;
c_2_2 = 4.48;
c_0_3 = 0.01176 ;
c_1_3 = 0.00077616;
c_2_3 = 4.48;
% Desired Speed
v_0 = 300;
% Desired Train Following Headway Time
hstar = 120;
a_1 = -1./m1.*(c_1_1 + 2.*c_2_1.*v_0);
a_2 = -1./m2.*(c_1_2 + 2.*c_2_2.*v_0);
a_3 = -1./m3.*(c_1_3 + 2.*c_2_3.*v_0);
a_1_head = 1-(a_1.*hstar);
a_2_head = 1-(a_2.*hstar);
a_3_head = 1-(a_3.*hstar);
b = 1;
p_1 = -1./m1.*(c_0_1 - c_2_1.*(v_0).^2);
p_2 = -1./m2.*(c_0_2 - c_2_2.*(v_0).^2);
p_3 = -1./m3.*(c_0_3 - c_2_3.*(v_0).^2);
I want to save this parameter into MAT file extension
save valueparameters.mat
But it can't save it said permission denied
Error using save
Unable to write file valueparameters.mat: permission denied.
Error in valueparameters (line 44)
save valueparameters.mat
How I save the file with mat extension?
6 Comments
Stephen23
on 19 Oct 2020
Edited: Stephen23
on 19 Oct 2020
"How i save not in installation folder?"
The simplest approach is to change the current directory to whatever directory you want to save your file in.
Do NOT use the installation folder of any application as the current directory.
Perhaps you ended up there by mistake, it really does not matter, the fact is, you need to change your current directory.
Accepted Answer
Tejas Turakhia
on 19 Oct 2020
This is working on my system:
clear all
clc
% Parameter Massa
m1 = 8095; % massa train set 1 dalam kg
m2 = 8500; % massa train set 2 dalam kg
m3 = 8457; % massa train set 3 dalam kg
% Parameter Gaya
f1 = 205.*10^3; % Gaya train set 1 dalam N
f2 = 302.*10^3; % Gaya train set 2 dalam N
f3 = 302.*10^3; % Gaya train set 3 dalam N
% Parameter Resistansi
c_0_1 = 0.01176;
c_1_1 = 0.00077616;
c_2_1 = 4.48 ;
c_0_2 = 0.01176 ;
c_1_2 = 0.00077616;
c_2_2 = 4.48;
c_0_3 = 0.01176 ;
c_1_3 = 0.00077616;
c_2_3 = 4.48;
% Desired Speed
v_0 = 300;
% Desired Train Following Headway Time
hstar = 120;
a_1 = -1./m1.*(c_1_1 + 2.*c_2_1.*v_0);
a_2 = -1./m2.*(c_1_2 + 2.*c_2_2.*v_0);
a_3 = -1./m3.*(c_1_3 + 2.*c_2_3.*v_0);
a_1_head = 1-(a_1.*hstar);
a_2_head = 1-(a_2.*hstar);
a_3_head = 1-(a_3.*hstar);
b = 1;
p_1 = -1./m1.*(c_0_1 - c_2_1.*(v_0).^2);
p_2 = -1./m2.*(c_0_2 - c_2_2.*(v_0).^2);
p_3 = -1./m3.*(c_0_3 - c_2_3.*(v_0).^2);
cd('your directory address'); % add this line to change the directory where file needs to be saved
save valueparameters.mat
3 Comments
Stephen23
on 19 Oct 2020
Rather than using cd in code (which slows code down and makes debugging more difficult) the cd command should be called just once (i.e. from the command line) to change the current directory.
To save files to a different directory using absolute/relative filenames is more efficient.
More Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!