MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by Tyler
on 5 Feb 2013

My goal: plot T1, T2, and T3 on a graph when the matrix is solved at each value of "i" from 0 to 50 for d. What my code currently does is solve a system at various values of "i" for three variables. the end result (aka the values I am trying to store) end up being T1, T2, and T3. The problem is, it only uses the last value of each of those, and not the entire spectrum of results. How can i store each result for those three values and plot them on a graph to show how they relate over time?

for d=0:.1:50;

i=d*-40000;

B=[-40000; i; 0];

A=[1 1 1; 10 28 40; 144 -240 180];

T=[(A^(-1)*B)];

T1=T(1);

T2=T(2);

T3=T(3);

end

*No products are associated with this question.*

Answer by Walter Roberson
on 5 Feb 2013

A = [1 1 1; 10 28 40; 144 -240 180];

dvals = 0:.1:50; for K = 1 : length(dvals) d = dvals(K); i = d * -40000; B = [-40000; i; 0]; T = A \ B; T1(K) = T(1); T2(K) = T(2); T3(K) = T(3); end

plot( dvals, T1, '^', dvals, T2, 's', dvals, T3, 'p')

## 0 Comments