Very simple simultaneous eqs.

1 vue (au cours des 30 derniers jours)
jnaumann
jnaumann le 8 Août 2011
I am working on a script to pinpoint acoustic sources from differences in arrival times. This is a very basic question but I'm new to Matlab so hopefully the answer will be very simple. This is what I have done so far.
function timediff
eq1 = '((D1^2-(t1^2)*(c^2))/(t1*c+D1*cos(y-theta1))*0.5)-x';
eq2 = '((D2^2-(t2^2)*(c^2))/(t2*c+D2*cos(theta3-y))*0.5)-x';
s=solve(eq1,eq2)
D1 = input('Enter value of D1: ');
D2 = input('Enter value of D2: ');
c = input('Enter value of speed of sound (c): ');
theta1 = input('Enter value of theta1: ');
theta3 = input('Enter value of theta3: ');
t1 = input('Enter value of time difference 1: ');
t2 = input('Enter value of time difference 2: ');
a=vpa(s.x)
b=vpa(s.y)
plot(a,b,'x')
When I run this and enter the paramaters it calculates a and b but doesn't evaluate them numerically - how do I do this because I would like to be able to plot them on a graph.
Many thanks in advance

Réponses (1)

Sean de Wolski
Sean de Wolski le 8 Août 2011
doc subs %substitute numerical values
doc double %convert symbolic to double precision
  2 commentaires
jnaumann
jnaumann le 8 Août 2011
I tried using the double command and the following error message was produced;
??? 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 936
Xstr = mupadmex('symobj::double', S.s, 0);
Error in ==> timediff at 12
a=double(s.x)
If I use the vpa command as suggested I still don't get the amsers in the numerical format.
Also how would i use the subs command because I have already entered the numerical values for the parameters?
Sean de Wolski
Sean de Wolski le 8 Août 2011
Use SUBS to substitute your values for D1 D2 c et al. into the s.x,s.y symbolics.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by