- Hold on and plot the result within the loop
Loop the Functions and store the values (placeholder) for Plotting
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I want to run the main functions from t=0:0.1:10. And to store the results for plotting e.g. e VS t
Tried this:
......
for t=1:0.1:10
[q_kp1,e] = Inverse(psm_x,k, psm_J, q_k, t);
[psm_J, psm_x]=FKp(q_kp1);
plot(e)
hold on;
end
But when I try to plot(e,t) or plot(t,e). It shows nothing......
Here is the script:
%%% assign initial values for psm_J, psm_x, q_k_0, k, q_k, psm_x_dsr %%
psm_m = psm_q_initial();
[psm_J, psm_x, q_k_0]=pFK(psm_m.DH);
k=100;
q_k = q_k_0;
%%% main functions %%%
[q_kp1,e] = Inverse(psm_x,k, psm_J, q_k, t);
[psm_J, psm_x]=FKp(q_kp1);
Please help.
0 commentaires
Réponse acceptée
YT
le 3 Déc 2018
Modifié(e) : YT
le 3 Déc 2018
There are 2 ways to solve this
figure();
hold on;
for t=1:0.1:10
[q_kp1,e] = Inverse(psm_x,k, psm_J, q_k, t);
[psm_J, psm_x]=FKp(q_kp1);
plot(t,e); %or plot(e,t) depends on what you want
end
hold off;
2. Save the values to an array and plot outside the loop
tV = [];%vector for t values
eV = [];%vector for e values
for t=1:0.1:10
[q_kp1,e] = Inverse(psm_x,k, psm_J, q_k, t);
[psm_J, psm_x]=FKp(q_kp1);
tV(end+1) = t;
eV(end+1) = e
end
figure();
plot(tV,eV);
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Line Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!