Info

This question is closed. Reopen it to edit or answer.

[GUID] Auto updating plot that uses subfunction

4 views (last 30 days)
Philippe Girard
Philippe Girard on 22 Mar 2018
Closed: MATLAB Answer Bot on 20 Aug 2021
Hi all, I have what I call a master challenge down here. I've been on this one for like 8 hours now I'm about to give up!
My problem is the following: this variable "mbs_invdyn.Qq(:,2)" comes from over 20 subfunction. This vector is influenced by the two following variables: "cdm" and "inertie".
I need a graphic with two handles, one for each of the two variables, and a "plot(tempsreel,abs(mbs_invdyn.Qq(:,2)))" like this one that update automatically. This can be through a GUID or an App. I know how to do basic GUID so I don't really need help on how to create it but more on how to create one that can use Subfunction and handle such as slide bar or editable value.
Thank you all for your help in advance!
MBS_user.process = 'invdyn'; actuated opt.invdyn = {'motion','trajectory','framerate',1000,... 'save2file','yes','renamefile','no','verbose','yes'}; % other options : 'time', 'visualize', 'clearmbsglobal' inertiemin = 0.011; inertiemax = 0.03; cdmmin = 0.1; cdmmax = 0.2; best = 100; %Pour l'intégrale plus bas tempsreel = [A verrrrrryyyyy long vector (1258 values)]; torquereel = [A verrrrrryyyyy long vector (1258 values)]; anglereel = [A verrrrrryyyyy long vector (1258 values)]; addpath('C:\Users\Philippe Girard\Documents\MBProjects\Question2Exo') cdm = 0.1207; inertie = 0.04; k = 1; figure() plot(tempsreel,torquereel,'Linewidth',2) hold on dt = tempsreel(2) - tempsreel(1); best_mean = 10;
f = torquereel; for i=1:length(f) if i==1 f_int(i) = 0; else f_int(i) = (f(i)+f(i-1))/2*dt+f_int(i-1); end end travail_total = f_int(end);
for i = 1:length(cdm) i mbs_data.l(1,2) = cdm(i); %position du centre de masse for j = 1:length(inertie) j mbs_data.In(1,2) = inertie(j); mbs_data.In(5,2) = inertie(j); mbs_data.In(9,2) = inertie(j); [mbs_invdyn,mbs_data] = mbs_exe_invdyn(mbs_data,opt.invdyn); % Inverse dynamics process erreur = mbs_invdyn.Qq(:,2)' - torquereel; %ici faut mettre le bonQq erreur_totale(k) = sum(abs(erreur)); k = k+1;
delta = abs(torquereel-mbs_invdyn.Qq(:,2)); f = delta; clear f_int for n=1:length(f) if n==1 f_int(n) = 0; else f_int(n) = (f(n)+f(n-1))/2*dt+f_int(n-1); end end diff = f_int(end);
if diff <= best
best = diff;
position = [i,j];
disp('Done for this thing now blablabalabalba;aba;ba;ab')
end
plot(tempsreel,abs(mbs_invdyn.Qq(:,2)))
axis([0 4 -inf inf])
end
end

Answers (0)

This question is closed.

Tags

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!