Error using plot Data must be numeric, datetime, duration or an array convertible to double

조회 수: 3 (최근 30일)
Hi,
May someone please clarify to me on how i can clear the above error message. i have tried using subs(), double() with no success. Anyway i am a basic MATLAB user.
x=[1680 1190 841 595 420 297 210 149 105 74.4 52.5 37.2 26.3 18.6 13.1 9.29 6.57 4.65 3.28 ...
2.32 1.64 1.16 0.821 0.581 0.00];
y=[99.872 98.945 95.538 88.050 76.599 62.936 49.281 37.107 27.087 19.425 13.696 9.996 7.296 5.325 ...
3.886 2.837 2.070 1.511 1.103 0.805 0.588 0.429 0.313 0.228 0.000];
a=3.79; b=3.31; c=0.36; d=0.54; f=1.11; g=0.24;Dc=0.5; h=1.5; Di=0.1; Do=0.083; Du=0.058; H=3; fi=0.198;
S=a*(Du/Do)^6*(Du^2+Do^2)^c*h^d*exp(0.54*fi)/(Dc^f*H^g);
F=50;
Rv=S/(S+1);
a1=2.69*10^3; b1=0.46; c1=0.6; d1=1.21; f1=0.71; g1=0.38; i1=0.45; ps=1841.525; pf=1000; Q=0.09352;
d50c=a1*Dc^b1*Di^c1*Do^d1*exp(6.3*fi)/(Du^f1*h^g1*Q^i1*(ps-pf)^0.5);
a2=2.96; b2=0.15;
lambda=a2*(Dc^2*h/Q)^b2*exp(-1.58*Rv);
x1=x./d50c;
edp=1-exp(-0.693.*x1.^lambda);
syms x y
summation=symsum(edp.*y/100*F);
Rf=(Rv-fi)*summation;
alpha=Rf;
cdp=alpha+(1-alpha).*edp;
Rs=symsum(cdp.*y./100*F);
pio=(1-cdp*y*F)./(symsum((1-cdp.*y*F)));
piu=(cdp*y*F)./(symsum((cdp.*y*F)));
plot(cdp,Rs);

답변 (2개)

Shadaab Siddiqie
Shadaab Siddiqie 2021년 2월 25일
From my understanding you are getting an error with above code. Please solve the expressions before plotting it. Please refer symbolic expression and solve for more information.
  댓글 수: 1
KIPROTICH KOSGEY
KIPROTICH KOSGEY 2021년 2월 26일
Hi Shadaab
Thanks for the suggestions but i couldn't make any progress either as i kept getting errors of a different nature:
Error using sym.getEqnsVars>checkVariables (line 92)
Second argument must be a vector of symbolic variables.
Error in sym.getEqnsVars (line 56)
checkVariables(vars);
Error in sym/solve>getEqns (line 429)
[eqns, vars] = sym.getEqnsVars(argv{:});
Error in sym/solve (line 226)
[eqns,vars,options] = getEqns(varargin{:});
Error in file (line 43)
Rs1=solve(Rs, varsRs,'Real',true);

댓글을 달려면 로그인하십시오.


Steven Lord
Steven Lord 2021년 2월 25일
Let's look at what you're trying to plot.
x=[1680 1190 841 595 420 297 210 149 105 74.4 52.5 37.2 26.3 18.6 13.1 9.29 6.57 4.65 3.28 ...
2.32 1.64 1.16 0.821 0.581 0.00];
y=[99.872 98.945 95.538 88.050 76.599 62.936 49.281 37.107 27.087 19.425 13.696 9.996 7.296 5.325 ...
3.886 2.837 2.070 1.511 1.103 0.805 0.588 0.429 0.313 0.228 0.000];
a=3.79; b=3.31; c=0.36; d=0.54; f=1.11; g=0.24;Dc=0.5; h=1.5; Di=0.1; Do=0.083; Du=0.058; H=3; fi=0.198;
S=a*(Du/Do)^6*(Du^2+Do^2)^c*h^d*exp(0.54*fi)/(Dc^f*H^g);
F=50;
Rv=S/(S+1);
a1=2.69*10^3; b1=0.46; c1=0.6; d1=1.21; f1=0.71; g1=0.38; i1=0.45; ps=1841.525; pf=1000; Q=0.09352;
d50c=a1*Dc^b1*Di^c1*Do^d1*exp(6.3*fi)/(Du^f1*h^g1*Q^i1*(ps-pf)^0.5);
a2=2.96; b2=0.15;
lambda=a2*(Dc^2*h/Q)^b2*exp(-1.58*Rv);
x1=x./d50c;
edp=1-exp(-0.693.*x1.^lambda);
syms x y
summation=symsum(edp.*y/100*F);
Rf=(Rv-fi)*summation;
alpha=Rf;
cdp=alpha+(1-alpha).*edp;
Rs=symsum(cdp.*y./100*F);
pio=(1-cdp*y*F)./(symsum((1-cdp.*y*F)));
piu=(cdp*y*F)./(symsum((cdp.*y*F)));
% plot(cdp,Rs);
cdp
cdp = 
Rs
Rs = 
Okay, those are long expressions. Let's approximate them:
vpa(cdp, 5)
ans = 
vpa(Rs, 5)
ans = 
Now at what x and y coordinates should the ninth point (as an example) be plotted?
vpa([cdp(9), Rs(9)], 5)
ans = 
Should it be left or right of the origin?
xcoord = double(subs(cdp(9), y, [1, -100]))
xcoord = 1×2
0.9876 -0.0943
If you meant to use the x and y vectors defined at the start of your code to evaluate cdp and Rs, don't redefine x and y as symbolic variables in the middle of your code or define those vectors with other names and maybe use subs to substitute those into the symbolic expressions you're trying to plot. The fact that your v vector is not a scalar may cause problems, though, in trying to get the correctly sized output. It's not clear to me what you're trying to do (no comments in your code) so I can't offer any further guidance.
  댓글 수: 1
KIPROTICH KOSGEY
KIPROTICH KOSGEY 2021년 2월 26일
Dear Steven,
Thanks for your efforts and offer to assist.
x represents the particle sizes and y represents the mass percentages. ideally i need to plot Rs vs x as well as Rs vs cdp. The reason why i used symbolic expressions is because i needed to do the summation for Rf, Rs, pio and piu. I haven't handled this kind of monsters before that is why i am struggling to plot!
Thanks in advance!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by