How to creating MAT file
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Stephen23
2020-10-19
编辑:Stephen23
2020-10-19
"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.
采纳的回答
Tejas Turakhia
2020-10-19
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 个评论
Stephen23
2020-10-19
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!