It shows: Undefined function 'vpasolve' for input arguments of type 'double' when I run it. Can I know how to solve this?
12 ビュー (過去 30 日間)
古いコメントを表示
clear all
clc
Q=((2000*42*(3.785*10^-3))/(1*24*3600)); %volumetric flowrate of fluid in m3/s
D=(4*0.0254); %inner diameter of pipe in m
A=(pi()*(D^2))/4; %cross sectional area of pipe in m2
rho=(0.9*1000); %density of fluid in kg/m3
miu=(8*0.001); %viscosity of fluid in Pa.s
Re=(rho*D*Q)/(miu*A); %Reynolds number
for rr=[0:0.002:0.008]; %relative roughness
%f is fricton factor
syms f
f=zeros(rr);
fn=1+2.*sqrt(f).*log(((rr)./3.7)+(2.51./(Re.*sqrt(f))));
f=double(vpasolve(fn==0,f,[0 1]))
end
0 件のコメント
採用された回答
John D'Errico
2019 年 2 月 15 日
編集済み: John D'Errico
2019 年 2 月 15 日
Is f a symbolic variable? (No.) We see this:
syms f
f=zeros(rr);
fn=1+2.*sqrt(f).*log(((rr)./3.7)+(2.51./(Re.*sqrt(f))));
f=double(vpasolve(fn==0,f,[0 1]))
So you created f as symbolic. And people seem to think that having done so, it will stay that way.
But in the very next line, you replace f.
f=zeros(rr);
f is now a double variable. Zero, in fact, although the first time through the loop, it will be empty, since rr will be 0.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Fluid Mechanics についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!