I have to try this code on Matlab's successful work. I want to try the subject in connection with external Arduino
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have to try this code on MATLAB's successful work. I want to try the subject in connection with an external Arduino. how can i do it pleas ??
The théori code is :
clear all;
close all
%%Load Data
load('IdealContollerData.mat')
load('OverdampedContollerData.mat')
load('UnderdampedContollerData.mat')
time = linspace(0,20,length(distance3));
%%Ideal Case
input = 20.*(time==0)+30.*((time~=0) & (time<=10)) + 20.*(time>10);
Gp = tf(0.617,[1 0 0]);
Gc = tf([1.4 0.6],1);
sys = feedback(Gp*Gc, 1);
figure
plot(time, input, 'g')
hold on
plot(time, distance,'r')
input2 = 10.*(time<=10);
y = lsim(sys,input2,time);
plot(time,y+20)
xlabel('Time (s)')
ylabel('Distance (cm)')
ylim([10,40])
title('Ideal Input & Response')
legend('Input','Experimental Response','Theoretical Response')
hold off
%%Underdamped Case
input = 20.*(time==0)+30.*((time~=0) & (time<=10)) + 20.*(time>10);
Gp = tf(0.617,[1 0 0]);
Gc = tf([1.3 0.8],1);
sys = feedback(Gp*Gc, 1);
figure
plot(time, input, 'g')
hold on
plot(time, distance2,'r')
input2 = 10.*(time<=10);
y = lsim(sys,input2,time);
plot(time,y+20)
xlabel('Time (s)')
ylabel('Distance (cm)')
ylim([10,40])
title('Underdamped Input & Response')
legend('Input','Experimental Response','Theoretical Response')
hold off
%%Overdamped Case
input = 20.*(time==0)+30.*((time~=0) & (time<=10)) + 20.*(time>10);
Gp = tf(0.617,[1 0 0]);
Gc = tf([2.5 0.3],1);
sys = feedback(Gp*Gc, 1);
figure
plot(time, input, 'g')
hold on
plot(time, distance3,'r')
input2 = 10.*(time<=10);
y = lsim(sys,input2,time);
plot(time,y+20)
xlabel('Time (s)')
ylabel('Distance (cm)')
ylim([10,40])
title('Overdamped Input & Response')
legend('Input','Experimental Response','Theoretical Response')
hold off
Réponses (0)
Voir également
Catégories
En savoir plus sur Modeling dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!