I have to try this code on Matlab's successful work. I want to try the subject in connection with external Arduino
1 次查看(过去 30 天)
显示 更早的评论
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
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Arduino Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!