I am having problems using syms

3 views (last 30 days)
Slavoj
Slavoj on 20 Oct 2014
Edited: Slavoj on 20 Oct 2014
Wrote a programe in Matlab2009b to solve a what seemed to be a simple physical problem. Now I am having trouble with syms x real, getting the same error over and over again:
??? Error using ==> mupadmex
Error in MuPAD command: DOUBLE cannot convert the input expression
into a double array.
If the input expression contains a symbolic variable, use the VPA
function instead.
Error in ==> sym.sym>sym.double at 927
Xstr = mupadmex('mllib::double', S.s, 0);
Error in ==> sym.sym>privformatscalar at 2539
x = double(x);
Error in ==> sym.sym>privformat at 2524
s = privformatscalar(x);
Error in ==> sym.sym>sym.subsasgn at 1418
[inds{k},refs{k}] = privformat(inds{k});
Error in ==> mnm1 at 8
vx(x)=sqrt(g.*(x^2*((1+u)/Lv)-2.*u.*x-b^2.*((1+u)/Lv)+2.*u.*b));
And the code is:
clc;clear all;format compact
Lv=6;
Lt=11;
b=4;
u=0.15;
g=9.81;
syms x real
vx(x)=sqrt(g*(x^2*((1+u)/Lv)-2*u*x-b^2*((1+u)/Lv)+2*u*b));
ax(x)=g.*(x-u*(Lv-x))/Lv;
dx=b:0.01:Lv;
a=ax(dx);
v=vx(dx);
vm=vx(dx);
hold on
plot(dx,a,'b')
plot(dx,v,'r')
ax(x)=g;
vx(x)=sqrt(2.*(x-Lv).*g+vm.^2);
dx=Lv:0.01:Lt;
a=ax(dx);
v=vx(dx);
plot(dx,a,'b');legend('a(x)','Location','best')
plot(dx,v,'r');legend('a(x)','Location','best','v(x)','Location','best')
xlabel('distance x[m]');ylabel('acceleration a[m/s^2]/velocity v[m/s]');
If I try to input numerical value for x for example x=(0:0.1:Lt), as this would be accurate enough and would also provide the correct interval, the error I get then is that matrix must square. I did also use
which -all syms
and I have the syms toolbox installed, so this does not seem to be a problem.
I am also fairly new to matlab and this seems to be a dead end for me. All help will be appreciated, thank you.

Answers (0)

Community Treasure Hunt

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

Start Hunting!