dot_net3.5异步收发socket--客户端

本文介绍了C# .NET 3.5中如何实现一个异步Socket客户端,包括SocketAsyncClient类的构造、SendMsg方法的异步发送以及ReceiveMSGEvent事件用于接收回发消息。示例代码展示了如何使用该类进行消息收发,并处理跨线程操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 说明:

作者:敖士伟

一、客户端收发类为SocketAsyncClient

1、构造函数SocketAsyncClient(string ip, Int32 port)初始远程主机IP和端口;

2、方法SendMsg(string msg)异步发送消息;

3、委托事件ReceiveMSGEvent接收回发消息。

 

二、使用此类的方法注册接收回发事件

 

类:

 

% --- main1.m --- % 此為主執行檔。 clear; clc; close all; % === 公共參數設定 === baseParams.Mp = 0.4753; baseParams.g = 9.81; baseParams.dm = 0.131; baseParams.J = 0.0103; baseParams.Jw = 0.0013; baseParams.b_theta = 5.6799e-6; baseParams.combined_b_alpha_term = 0.0131; baseParams.combined_km_Ra_term = 0.0447; baseParams.Ra = 2; baseParams.ke = 0.1; baseParams.km = baseParams.combined_km_Ra_term * baseParams.Ra; baseParams.b_alpha = baseParams.combined_b_alpha_term - ... (baseParams.km * baseParams.ke) / baseParams.Ra; baseParams.tau_d = 0; baseParams.alpha_ref = 0; baseParams.u_max = 12; baseParams.u_min = -12; time_start = 0; time_end = 0.5; test_angle = 0.2; % ========== 模擬 1:內迴路 PID 控制 ========== params1 = baseParams; params1.integral_error = 0; params1.alpha_ref = 0; params1.Kp_in = 10; params1.Ki_in = 5; params1.Kd_in = 3; x0_1 = [test_angle; 0; 0; 0; 0]; % [theta; theta_dot; alpha; alpha_dot; E_in] tspan1 = [time_start time_end]; options = odeset(&#39;RelTol&#39;, 1e-12, &#39;AbsTol&#39;, 1e-12); [t1, x1] = ode45(@(t, x) dynamics(t, x, params1), tspan1, x0_1,options); u1 = zeros(size(t1)); theta_ref1 = zeros(size(t1)); for i = 1:length(t1) [~, u, theta_ref] = dynamics(t1(i), x1(i,:)&#39;, params1); u1(i) = u; theta_ref1(i) = theta_ref; end % --- fuzzy_controller2.m --- function theta_ref = fuzzy_controller2(e, de) % === 範圍定義 === e_min = -50; e_max = 50; de_min = -50; de_max = 50; centers = [-10, -5, 0, 5, 10]; % === 定義三角形隸屬函數 === mf_e = define_mf(e_min, e_max, centers); mf_de = define_mf(de_min, de_max, centers); fprintf("e = %.4f\n", e); fprintf("de = %.4f\n", de); % === 模糊化 === mu_e = fuzzify(e, mf_e); mu_de = fuzzify(de, mf_de); rule_matrix = [ 1 1 2 3 4 1 2 3 3 5 2 3 3 3 2 5 3 3 2 1 3 3 2 1 1 ]; % === 推論輸出權重 === output_strength = zeros(1, 5); for i = 1:5 for j = 1:5 activation = min(mu_e(i), mu_de(j)); k = rule_matrix(i, j); output_strength(k) = max(output_strength(k), activation); end end % === 解模糊=== numerator = sum(output_strength .* centers); denominator = sum(output_strength); theta_ref = 1 * (numerator / denominator); end % 定義隸屬度函數 (三角形) function mf = define_mf(min_val, max_val, centers) n = length(centers); mf = cell(1, n); for i = 1:n if i == 1 a = min_val; else a = centers(i - 1); end b = centers(i); if i == n c = max_val; else c = centers(i + 1); end mf{i} = [a, b, c]; end end % 模糊化函數 function mu = fuzzify(value, mf) n = length(mf); mu = zeros(1, n); for i = 1:n a = mf{i}(1); b = mf{i}(2); c = mf{i}(3); if value <= a || value >= c mu(i) = 0; elseif value >= a && value <= b mu(i) = (value - a) / (b - a); else mu(i) = (c - value) / (c - b); end end end function [dxdt, u, theta_ref] = dynamics(~, x, params) % 解包狀態 theta = x(1); theta_dot = x(2); alpha = x(3); alpha_dot = x(4); E_in = x(5); % 內迴路 PID 積分 % === 外迴路模糊控制器 === error_out = params.alpha_ref - alpha; error_dot_out = -alpha_dot; fprintf("error_out = %.4f\n", error_out); fprintf("error_dot_out = %.4f\n", error_dot_out); theta_ref = fuzzy_controller2(error_out, error_dot_out); fprintf("theta = %.4f\n", theta); fprintf("theta_ref = %.4f\n", theta_ref); fprintf("alpha = %.4f\n", alpha); % === 內迴路 PID 控制器 === error_in_pid = theta_ref - theta; error_dot_in = -theta_dot; fprintf("error_in_pid = %.4f\n", error_in_pid); fprintf("error_dot_in = %.4f\n--------\n", error_dot_in); u = params.Kp_in * error_in_pid + params.Ki_in * E_in + params.Kd_in * error_dot_in; u = max(min(u, params.u_max), params.u_min); % 飽和限制 fprintf("u = %.4f\n", u); % === 抗積分飽和 === if u >= params.u_max || u <= params.u_min dE_in_dt = 0; else dE_in_dt = error_in_pid; end % === 動態模型 === Mp = params.Mp; g = params.g; dm = params.dm; J = params.J; Jw = params.Jw; b_theta = params.b_theta; b_alpha_term = params.combined_b_alpha_term; km_Ra = params.combined_km_Ra_term; tau_d = params.tau_d; theta_ddot = ((Mp * dm * g) / J) * sin(theta) - ... (b_theta / J) * theta_dot + ... (1 / J) * b_alpha_term * alpha_dot + ... (1 / J) * tau_d - ... (km_Ra / J) * u; alpha_ddot = -((Mp * g * dm) / J) * sin(theta) + ... (b_theta / J) * theta_dot - ... ((J + Jw) / (J * Jw)) * b_alpha_term * alpha_dot - ... (1 / J) * tau_d + ... ((J + Jw) / (J * Jw)) * km_Ra * u; dxdt = [theta_dot; theta_ddot; alpha_dot; alpha_ddot; dE_in_dt;]; end -------- u = -12.0000 error_out = 16.0302 error_dot_out = 38.4436 e = 16.0302 de = 38.4436 theta = 4.8086 theta_ref = -10.0000 alpha = -16.0302 error_in_pid = -14.8086 error_dot_in = -10.9737 -------- u = -12.0000 error_out = 16.0502 error_dot_out = 38.4278 e = 16.0502 de = 38.4278 theta = 4.8143 theta_ref = -10.0000 alpha = -16.0502 error_in_pid = -14.8143 error_dot_in = -10.9447 -------- u = -12.0000 error_out = 16.0701 error_dot_out = 38.4120 e = 16.0701 de = 38.4120 theta = 4.8199 theta_ref = -10.0000 alpha = -16.0701 error_in_pid = -14.8199 error_dot_in = -10.9157 -------- u = -12.0000 error_out = 16.0901 error_dot_out = 38.3964 e = 16.0901 de = 38.3964 theta = 4.8256 theta_ref = -10.0000 alpha = -16.0901 error_in_pid = -14.8256 error_dot_in = -10.8868 -------- u = -12.0000 error_out = 16.1100 error_dot_out = 38.3809 e = 16.1100 de = 38.3809 theta = 4.8313 theta_ref = -10.0000 alpha = -16.1100 error_in_pid = -14.8313 error_dot_in = -10.8578 -------- u = -12.0000 error_out = 16.1296 error_dot_out = 38.3657 e = 16.1296 de = 38.3657 theta = 4.8368 theta_ref = -10.0000 alpha = -16.1296 error_in_pid = -14.8368 error_dot_in = -10.8294 -------- u = -12.0000 error_out = 16.1493 error_dot_out = 38.3506 e = 16.1493 de = 38.3506 theta = 4.8423 theta_ref = -10.0000 alpha = -16.1493 error_in_pid = -14.8423 error_dot_in = -10.8010 -------- u = -12.0000 error_out = 16.1689 error_dot_out = 38.3357 e = 16.1689 de = 38.3357 theta = 4.8479 theta_ref = -10.0000 alpha = -16.1689 error_in_pid = -14.8479 error_dot_in = -10.7726 -------- u = -12.0000 error_out = 16.1885 error_dot_out = 38.3208 e = 16.1885 de = 38.3208 theta = 4.8534 theta_ref = -10.0000 alpha = -16.1885 error_in_pid = -14.8534 error_dot_in = -10.7443 -------- u = -12.0000 error_out = 16.2078 error_dot_out = 38.3063 e = 16.2078 de = 38.3063 theta = 4.8588 theta_ref = -10.0000 alpha = -16.2078 error_in_pid = -14.8588 error_dot_in = -10.7163 -------- u = -12.0000 error_out = 16.2271 error_dot_out = 38.2919 e = 16.2271 de = 38.2919 theta = 4.8642 theta_ref = -10.0000 alpha = -16.2271 error_in_pid = -14.8642 error_dot_in = -10.6885 -------- u = -12.0000 error_out = 16.2465 error_dot_out = 38.2775 e = 16.2465 de = 38.2775 theta = 4.8696 theta_ref = -10.0000 alpha = -16.2465 error_in_pid = -14.8696 error_dot_in = -10.6606 -------- u = -12.0000 error_out = 16.2658 error_dot_out = 38.2633 e = 16.2658 de = 38.2633 theta = 4.8749 theta_ref = -10.0000 alpha = -16.2658 error_in_pid = -14.8749 error_dot_in = -10.6328 -------- u = -12.0000 error_out = 16.2848 error_dot_out = 38.2494 e = 16.2848 de = 38.2494 theta = 4.8802 theta_ref = -10.0000 alpha = -16.2848 error_in_pid = -14.8802 error_dot_in = -10.6053 -------- u = -12.0000 error_out = 16.3039 error_dot_out = 38.2356 e = 16.3039 de = 38.2356 theta = 4.8855 theta_ref = -10.0000 alpha = -16.3039 error_in_pid = -14.8855 error_dot_in = -10.5779 -------- u = -12.0000 error_out = 16.3229 error_dot_out = 38.2218 e = 16.3229 de = 38.2218 theta = 4.8908 theta_ref = -10.0000 alpha = -16.3229 error_in_pid = -14.8908 error_dot_in = -10.5506 -------- u = -12.0000 error_out = 16.3420 error_dot_out = 38.2082 e = 16.3420 de = 38.2082 theta = 4.8960 theta_ref = -10.0000 alpha = -16.3420 error_in_pid = -14.8960 error_dot_in = -10.5232 -------- u = -12.0000 error_out = 16.3608 error_dot_out = 38.1948 e = 16.3608 de = 38.1948 theta = 4.9012 theta_ref = -10.0000 alpha = -16.3608 error_in_pid = -14.9012 error_dot_in = -10.4962 -------- u = -12.0000 error_out = 16.3796 error_dot_out = 38.1816 e = 16.3796 de = 38.1816 theta = 4.9064 theta_ref = -10.0000 alpha = -16.3796 error_in_pid = -14.9064 error_dot_in = -10.4693 -------- u = -12.0000 error_out = 16.3984 error_dot_out = 38.1684 e = 16.3984 de = 38.1684 theta = 4.9115 theta_ref = -10.0000 alpha = -16.3984 error_in_pid = -14.9115 error_dot_in = -10.4423 -------- u = -12.0000 error_out = 16.4172 error_dot_out = 38.1554 e = 16.4172 de = 38.1554 theta = 4.9166 theta_ref = -10.0000 alpha = -16.4172 error_in_pid = -14.9166 error_dot_in = -10.4155 -------- u = -12.0000 error_out = 16.4358 error_dot_out = 38.1425 e = 16.4358 de = 38.1425 theta = 4.9217 theta_ref = -10.0000 alpha = -16.4358 error_in_pid = -14.9217 error_dot_in = -10.3889 -------- u = -12.0000 error_out = 16.4544 error_dot_out = 38.1298 e = 16.4544 de = 38.1298 theta = 4.9268 theta_ref = -10.0000 alpha = -16.4544 error_in_pid = -14.9268 error_dot_in = -10.3624 -------- u = -12.0000 error_out = 16.4730 error_dot_out = 38.1172 e = 16.4730 de = 38.1172 theta = 4.9318 theta_ref = -10.0000 alpha = -16.4730 error_in_pid = -14.9318 error_dot_in = -10.3359 -------- u = -12.0000 error_out = 16.4916 error_dot_out = 38.1047 e = 16.4916 de = 38.1047 theta = 4.9369 theta_ref = -10.0000 alpha = -16.4916 error_in_pid = -14.9369 error_dot_in = -10.3094 -------- u = -12.0000 error_out = 16.5100 error_dot_out = 38.0924 e = 16.5100 de = 38.0924 theta = 4.9418 theta_ref = -10.0000 alpha = -16.5100 error_in_pid = -14.9418 error_dot_in = -10.2832 -------- u = -12.0000 error_out = 16.5284 error_dot_out = 38.0802 e = 16.5284 de = 38.0802 theta = 4.9468 theta_ref = -10.0000 alpha = -16.5284 error_in_pid = -14.9468 error_dot_in = -10.2571 -------- u = -12.0000 error_out = 16.5468 error_dot_out = 38.0681 e = 16.5468 de = 38.0681 theta = 4.9517 theta_ref = -10.0000 alpha = -16.5468 error_in_pid = -14.9517 error_dot_in = -10.2310 -------- u = -12.0000 error_out = 16.5652 error_dot_out = 38.0561 e = 16.5652 de = 38.0561 theta = 4.9567 theta_ref = -10.0000 alpha = -16.5652 error_in_pid = -14.9567 error_dot_in = -10.2050 -------- u = -12.0000 error_out = 16.5806 error_dot_out = 38.0461 e = 16.5806 de = 38.0461 theta = 4.9608 theta_ref = -10.0000 alpha = -16.5806 error_in_pid = -14.9608 error_dot_in = -10.1832 -------- u = -12.0000 error_out = 16.5960 error_dot_out = 38.0361 e = 16.5960 de = 38.0361 theta = 4.9649 theta_ref = -10.0000 alpha = -16.5960 error_in_pid = -14.9649 error_dot_in = -10.1614 -------- u = -12.0000 error_out = 16.6114 error_dot_out = 38.0263 e = 16.6114 de = 38.0263 theta = 4.9690 theta_ref = -10.0000 alpha = -16.6114 error_in_pid = -14.9690 error_dot_in = -10.1396 -------- u = -12.0000 error_out = 16.6268 error_dot_out = 38.0165 e = 16.6268 de = 38.0165 theta = 4.9731 theta_ref = -10.0000 alpha = -16.6268 error_in_pid = -14.9731 error_dot_in = -10.1179 -------- u = -12.0000
最新发布
07-31
<think>我们注意到在运行过程中,控制输入u一直处于饱和状态(u=-12),并且theta_ref始终为-10。这可能是由于模糊控制器的输出theta_ref被限制在了-10。 观察模糊控制器fuzzy_controller2.m,我们发现以下问题: 1. 在解模糊时,theta_ref = 1 * (numerator / denominator); 这里乘以1,但实际输出范围可能超出预期。 2. 模糊控制器的输入e和de的范围是[-50,50],而输出中心点为[-10,-5,0,5,10]。但在解模糊时,我们直接使用了这些中心点,没有进行缩放。 3. 在规则矩阵中,我们使用了1到5的整数,对应中心点的索引。但是,当输出权重的分母为0时(即没有任何规则被激活),会导致除以0错误(虽然当前输出没有出现,但需要防范)。 然而,从打印的e和de的值来看(例如e=16.0302, de=38.4436),这些值都在定义的范围[-50,50]内,所以不会因为超出范围而无法计算隶属度。 但是,为什么theta_ref总是-10呢? 我们检查模糊控制器的计算过程: 1. 模糊化:计算e和de在5个隶属函数上的隶属度。 2. 规则矩阵:根据规则矩阵,每个规则对应一个输出语言变量(1到5,分别代表负大、负小、零、正小、正大?) 3. 输出强度:对每个输出语言变量,取所有激活规则中的最大隶属度作为该输出的强度。 4. 解模糊:用输出强度加权中心点,然后除以总强度。 问题可能出在规则矩阵的设计上。我们观察规则矩阵: rule_matrix = [ 1 1 2 3 4 1 2 3 3 5 2 3 3 3 2 5 3 3 2 1 3 3 2 1 1 ]; 这个规则矩阵的含义是:行表示e的隶属函数(从负到正5个),列表示de的隶属函数(从负到正5个),值代表输出的语言变量索引。 例如,当e为第一个隶属函数(负大)且de为第一个隶属函数(负大)时,输出为1(负大,对应中心点-10)。 当e和de都很大(正大)时,即最后一行最后一列,输出为1(负大?)?这看起来不合理。 实际上,当误差e为正(即alpha小于设定值,因为error_out=alpha_ref-alpha,而alpha_ref=0,所以alpha为负时误差为正)且误差变化率de为正(即alpha_dot为负,因为error_dot_out=-alpha_dot,所以alpha_dot为负时de为正)时,我们应该增加theta_ref(使theta_ref为正)以减小alpha的负值(即让alpha往正方向走)。但是规则矩阵最后一行最后一列输出1(负大)会使得theta_ref为负,这显然是不合理的。 因此,规则矩阵的设计可能存在问题。另外,我们注意到当e和de都很大时,激活的规则应该是输出正大的控制量,但这里规则矩阵给出的是1(负大)。 另外,我们注意到在计算输出强度时,我们初始化output_strength为zeros(1,5),然后对每个规则,取激活强度(隶属度的最小值)与当前该输出的强度比较取大。但是,如果没有任何规则激活某个输出,那么该输出的强度为0,在解模糊时就会忽略这个输出。 但是,从打印的e和de来看,它们都比较大(正),所以应该激活的是e和de的最后一个或两个隶属函数(即正大)。我们检查模糊化部分: 例如,e=16.0302,隶属函数定义: centers = [-10,-5,0,5,10] 最后一个隶属函数:中心点为10,其三角形为[5,10,50](因为max_val=50,所以c=50)。所以对于e=16.0302,它在最后一个隶属函数上的隶属度为: a=5, b=10, c=50 mu = (50-16.0302)/(50-10) = (33.9698)/40 ≈ 0.8492 同样,de=38.4436,最后一个隶属函数:a=5, b=10, c=50,所以 mu = (50-38.4436)/40 = 11.5564/40 ≈ 0.2889 那么激活的规则是:e的第五个隶属函数和de的第五个隶属函数,即规则矩阵(5,5)=1(负大)。所以输出语言变量1的强度为min(0.8492,0.2889)=0.2889。 同时,e的第五个隶属函数和de的第四个隶属函数(de=38.4436在第四个隶属函数上的隶属度?第四个隶属函数:中心5,三角形[0,5,10]?显然38.4436不在这个三角形内,所以隶属度为0。同理,e的第四个隶属函数(中心5,三角形[0,5,10])对于e=16.0302的隶属度也为0(因为16>10)。所以只有规则(5,5)被激活?那么输出只有语言变量1(负大)被激活,强度0.2889。 因此,解模糊:theta_ref = (0.2889 * (-10)) / 0.2889 = -10。 这就是为什么theta_ref总是-10的原因:因为当e和de都很大(正)时,规则矩阵(5,5)指向了1(负大),而其他规则没有被激活。 所以,我们需要重新设计规则矩阵。通常,当误差和误差变化率都为正时,我们应该输出正的控制量(即正大)。因此,规则矩阵的最后一行最后一列应该是5(正大)而不是1。 修改规则矩阵为: rule_matrix = [ 1, 1, 1, 2, 3; 1, 1, 2, 3, 4; 1, 2, 3, 4, 5; 2, 3, 4, 5, 5; 3, 4, 5, 5, 5 ]; 或者更常见的做法(对角线为同一类): rule_matrix = [ 1, 1, 2, 3, 4; 1, 2, 3, 4, 5; 2, 3, 4, 5, 5; 3, 4, 5, 5, 5; 4, 5, 5, 5, 5 ]; 但具体需要根据控制逻辑调整。 这里我们采用常见的规则:当误差和误差变化率都为正大时,输出正大(5)。所以将(5,5)改为5。 同时,我们还需要注意,当没有任何规则激活时(分母为0),需要给一个默认输出(比如0)。 因此,修改fuzzy_controller2.m中的解模糊部分: if denominator == 0 theta_ref = 0; else theta_ref = 1 * (numerator / denominator); end 另外,我们也可以考虑对输出进行缩放。目前中心点是[-10,-5,0,5,10],而实际我们可能希望输出在[-20,20]之间,那么可以乘以一个增益(比如2)。但这里我们先不改变,等调试规则后再看。 修改后的模糊控制器函数如下(只修改了规则矩阵和添加分母为0的判断):</think>根据提供的代码和运行结果,主要问题在于模糊控制器`fuzzy_controller2`的输出始终为`-10`,导致内环PID持续饱和(`u=-12`)。以下是详细分析和解决方案: ### 问题原因分析 1. **规则矩阵设计错误** - 当前规则矩阵: ```matlab rule_matrix = [ 1 1 2 3 4 1 2 3 3 5 2 3 3 3 2 5 3 3 2 1 3 3 2 1 1 ]; ``` - 当误差`e`和误差变化率`de`均为正大时(对应右下角元素),规则输出为`1`(负大),但正确逻辑应为输出正大(`5`)。 2. **未处理零激活规则** 当`output_strength`全为0时(无规则激活),解模糊计算`numerator/denominator`会导致`NaN`(未发生但需预防)。 3. **输出范围过小** 中心点`centers = [-10, -5, 0, 5, 10]`的范围不足以覆盖控制需求(实际误差`e`已达16)。 ### 解决方案 #### 1. 修正规则矩阵 ```matlab % 新规则矩阵(行:e的隶属度,列:de的隶属度) rule_matrix = [ 1 1 2 3 4; % e: NB 1 2 3 4 5; % e: NS 2 3 4 5 5; % e: ZE 3 4 5 5 5; % e: PS 4 5 5 5 5 % e: PB ]; ``` **解释**:当`e`和`de`均为正大(PB)时,输出正大(`5`),符合控制逻辑。 #### 2. 添加零激活处理 ```matlab % 解模糊前添加判断 if denominator == 0 theta_ref = 0; % 默认输出 else theta_ref = 1 * (numerator / denominator); end ``` #### 3. 扩展输出范围 ```matlab % 修改中心点范围(扩大至±30) centers = [-30, -15, 0, 15, 30]; ``` **解释**:适应实际误差范围(`e`≈16),避免输出饱和。 ### 完整修正代码 ```matlab function theta_ref = fuzzy_controller2(e, de) % === 范围定义 === e_min = -50; e_max = 50; de_min = -50; de_max = 50; centers = [-30, -15, 0, 15, 30]; % 扩展输出范围 % === 定义三角形隶属函数 === mf_e = define_mf(e_min, e_max, centers); mf_de = define_mf(de_min, de_max, centers); % === 模糊化 === mu_e = fuzzify(e, mf_e); mu_de = fuzzify(de, mf_de); % === 修正规则矩阵 === rule_matrix = [ 1 1 2 3 4; % e: NB 1 2 3 4 5; % e: NS 2 3 4 5 5; % e: ZE 3 4 5 5 5; % e: PS 4 5 5 5 5 % e: PB ]; % === 推论输出权重 === output_strength = zeros(1, 5); for i = 1:5 for j = 1:5 activation = min(mu_e(i), mu_de(j)); k = rule_matrix(i, j); output_strength(k) = max(output_strength(k), activation); end end % === 解模糊(含零激活保护)=== numerator = sum(output_strength .* centers); denominator = sum(output_strength); if denominator == 0 theta_ref = 0; % 默认值 else theta_ref = 1 * (numerator / denominator); end end ``` ### 其他优化建议 1. **添加抗饱和重置逻辑** 在`dynamics.m`中,当`u`饱和时重置积分项: ```matlab if u >= params.u_max || u <= params.u_min dE_in_dt = 0; % 当前已有 params.integral_error = 0; % 添加:重置积分项 end ``` 2. **调整PID参数** 当前`Kp_in=10, Ki_in=5, Kd_in=3`可能过大,建议逐步调整: ```matlab params1.Kp_in = 5; % 降低比例增益 params1.Ki_in = 2; % 降低积分增益 params1.Kd_in = 1; % 降低微分增益 ``` 3. **检查初始状态** 初始角度`x0_1 = [test_angle; 0; 0; 0; 0]`中`test_angle=0.2`(约11.5°),确保符合物理约束。 ### 验证步骤 1. 用修正后的`fuzzy_controller2`替换原函数。 2. 运行`main1.m`观察`theta_ref`和`u`是否脱离饱和。 3. 绘制响应曲线验证控制效果: ```matlab figure; subplot(2,1,1); plot(t1, x1(:,3)); title(&#39;Alpha&#39;); subplot(2,1,2); plot(t1, u1); title(&#39;Control Input&#39;); ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值