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
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
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
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 CenterFile Exchange 中查找有关 Manage Products 的更多信息

标签

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by