我想根据施加的电流创建一个螺旋桨角速度的 Matlab 图。关键是,这需要结合两组相互依赖的数据。
首先,阻力系数c_d
取决于角速度omega
(我没有公式,只有数据),如下图所示 - 特征c_d(omega)
可以很容易地线性化为c_d(omega) = p*omega + p_0
。
其次,omega
不仅取决于施加的电流i
,还取决于阻力系数c_d(omega)
。
解决这种情况的脚本,c_d
下面是常量。必须以某种方式使用 Matlab 命令将这两者结合起来。谢谢你的帮助。
%%Lookup table for drag coefficient c_d
c_d_lookup = [248.9188579 0.036688351; %[\omega c_d]
280.2300647 0.037199094;
308.6091183 0.037199094;
338.6636881 0.03779496;
365.8908244 0.038305703;
393.9557188 0.039156941;
421.9158934 0.039667683;
452.2846224 0.040348674;
480.663676 0.041199911;
511.032405 0.042051149;
538.9925796 0.042561892;
567.2669135 0.043242882;
598.4734005 0.043668501;
624.1297405 0.044264368;
651.9851954 0.044604863;
683.6105614 0.045200729];
subplot(2,1,1)
plot(c_d_lookup(:,1), c_d_lookup(:,2))
title('This is how c_d depends on \omega')
ylabel('c_d')
xlabel('\omega [rad/s]')
%%Calculate propeller angular speed in terms of applied current. omega
%%depends on c_d, which in turn depends on omega. The formula is:
% omega(i) = sqrt(a*i / (b * c_d(omega)))
% Where:
% i - applied current
% omega - propeller angular velocity
% a,b - coefficients
i = [1:15];
a = 0.0718;
b = 3.8589e-005;
%If c_d was constant, I'd do:
omega_i = sqrt(a .* i / (b * 0.042));
subplot(2,1,2)
plot(i, omega_i)
ylabel({'Propeller ang. vel.', '\omega [rad/s]'})
xlabel('Applied current i[A]')
title('Propeller angular velocity in terms of applied current')
编辑:
试图遵循bdecaf 的解决方案。所以我创建了一个函数c_d_find
,如下所示:
function c_d = c_d_find(omega, c_d_lookup)
c_d = interp1(c_d_lookup(:,1), c_d_lookup(:,2), omega, 'linear', 'extrap');
end
我对 Matlab 函数句柄一无所知,但似乎理解这个想法......在 Matlab 命令窗口中,我键入:
f = @(omega) omega - sqrt(a .* i / (b * c_d_find(omega, c_d_lookup)))
我希望创建正确的函数句柄。接下来我该怎么做?执行以下不起作用:
>> omega_consistent = fzero(f,0)
??? Operands to the || and && operators must be convertible to logical scalar
values.
Error in ==> fzero at 333
elseif ~isfinite(fx) || ~isreal(fx)