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

Click For Summary
SUMMARY

The discussion focuses on simplifying Matlab source code for GUI implementation, specifically for a PID controller simulation. The user seeks to automate the assignment of the variable "kn" based on user input for "n" within a loop. A suggested solution involves restructuring the code to utilize an array for gains, allowing for dynamic assignment of "kn" as "gains(k,n)" within an outer loop. This approach enhances code readability and functionality in a GUI context.

PREREQUISITES
  • Familiarity with Matlab programming
  • Understanding of PID control systems
  • Basic knowledge of GUI development in Matlab
  • Experience with matrix operations in Matlab
NEXT STEPS
  • Explore Matlab GUI development techniques
  • Learn about Matlab array manipulation and indexing
  • Study PID controller design and tuning in Matlab
  • Investigate the use of the 'sim' function in Matlab for simulations
USEFUL FOR

Matlab programmers, control system engineers, and developers working on GUI applications who need to implement dynamic data handling in simulations.

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
 

Similar threads

Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 9 ·
Replies
9
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K