function solve return 'Unable to perform assignment because the left and right sides have a different number of elements.'

1 次查看(过去 30 天)
Hi everyone,
trying to run this code where every parameter is known, only 'gamma' is my variable and 'hs_data' is a known function of 't_data'
hs_data = hs_Lderiv./1000; %meter
t_data = t; %seconds
dh = diff(hs_data);
dt = diff(t_data);
syms gamma
dhdt = zeros(size(t_data)-1);
gammaL = zeros(size(hs_data)-1);
gammaH = zeros(size(hs_data)-1);
for n = 1:length(t_data)-1
dhdt(n)= dh(n)./dt(n);
gammaL(n) = solve(dhdt(n) == -(1.2269.*gamma.*a_channel.^7.*hs_data(n).^4)./(pi().*mu.*L.*(a_source.^2+hs_data(n).^2).^5), gamma);
gammaH(n) = solve(dhdt(n) == -((2.*gamma)./(26.08.*pi().*mu.*a_channel.*L.*(a_source.^2+hs_data(n).^2))).*((((2.*a_channel.^2.*hs_data(n))./(a_source.^2+hs_data(n).^2))-((dRho.*g.*a_channel.^2.*hs_data(n))./(2.*gamma))).^4), gamma);
end
the first function 'solve' (the one returnin 'gammaL') works perfectly but the second one always returns the error 'Unable to perform assignment because the left and right sides have a different number of elements.'
is there a very trivial error i cannot find?
thank you very much in advance

回答(1 个)

KSSV
KSSV 2022-1-21
hs_data = hs_Lderiv./1000; %meter
t_data = t; %seconds
dh = diff(hs_data);
dt = diff(t_data);
syms gamma
dhdt = zeros(size(t_data)-1);
gammaL = cell(size(hs_data)-1,1);
gammaH = cell(size(hs_data)-1,1);
for n = 1:length(t_data)-1
dhdt(n)= dh(n)./dt(n);
gammaL{n} = solve(dhdt(n) == -(1.2269.*gamma.*a_channel.^7.*hs_data(n).^4)./(pi().*mu.*L.*(a_source.^2+hs_data(n).^2).^5), gamma);
gammaH{n} = solve(dhdt(n) == -((2.*gamma)./(26.08.*pi().*mu.*a_channel.*L.*(a_source.^2+hs_data(n).^2))).*((((2.*a_channel.^2.*hs_data(n))./(a_source.^2+hs_data(n).^2))-((dRho.*g.*a_channel.^2.*hs_data(n))./(2.*gamma))).^4), gamma);
end

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by