Macros in Matlab - repeating simple instructions
显示 更早的评论
Hi there,
I have read on some websites that writing macros for Matlab is not advisable? I am trying to write several as I am about to be embarking on the same process for a number of different data sets. twenty five to be exact. I would like to do simple things like write macro to call my data set put it through two or three functions that I have written and then save the results in a particular place. Is that possible? Is there any good literature I can get on the topic?
采纳的回答
更多回答(3 个)
Walter Roberson
2014-2-18
0 个投票
For something like that you would likely be better off writing functions.
But yes, you can write scripts. scripts run in the context of the current workspace.
1 个评论
covariant_cat
2018-6-6
How do you deal with import? Neither another function nor another script can import packages for a function.
liam
26 minutes 前
0 个投票
disp('**********************************************
*****');
disp('** Matlab Macro for simulation first order
system **');
disp('** a2 dy/dt + a1 y(t) = b1 u(t) **');
disp('**********************************************
*****');
disp(' ');
T=input('input Integration time= ');
t_sim=input('input total simulation time= ');
ts=input('input first integration time= ');
a1=input('input model paramter a1= ');
a2=input('input model paramter a2= ');
b1=input('input model paramter b1= ');
vo=0;
k=1;
vi=1;alf=(1/(a2+(a1*T)));
for(t=ts:T:t_sim)
y=(alf*a2)*vo+(alf)*T*b1*vi;
vo=y;
out(k)=y;
xt(k)=t;
k=k+1;
end
plot(xt,out);
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!