How Can I Simplify This Matlab Source Code for GUI Implementation?

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 4K views
fsven
Messages
1
Reaction score
0
Hi, Matlab noob here.

I need your help to simplify this Matlab source code. Here the code that i currently use

for k=1:1:gg
k1=gains(k,1);
k2=gains(k,2);
k3=gains(k,3);
.
.
kn=pidgains(k,n)


[T,X,Y]=sim('Evaporator_PID',[Tstart Tfinal],opt);

end​

The code above need to implement into GUI and the "n" is a value that assign by user. So i need to create a code that can generate the "kn=gains(k,n);" automatically.
"gains" is matrix like "54xn".

Thanks in advance.
 
Physics news on Phys.org
it would probably be easiest to make your gains an arrray such that
k(n) = gains(k,n)

and place that in an outer loop