Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8585823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:09:44+00:00 2026-06-11T22:09:44+00:00

I want to solve equations in matlab, eg. 100+a/2=173*cos(b) sqrt(3)*a/2=173*sin(b) and the code would

  • 0

I want to solve equations in matlab, eg.

100+a/2=173*cos(b) 

sqrt(3)*a/2=173*sin(b)

and the code would be:

[a,b]=solve('100+a/2=173*cos(b)','sqrt(3)*a/2=173*sin(b)','a','b')

However, if I want to take 100 as a variable, like

for k=1:100

  [a,b]=solve('k+a/2=173*cos(b)','sqrt(3)*a/2=173*sin(b)','a','b')

end

There would be an error, how to make it?

degree=140/1000000;
p=42164000;
a=6378136.5;
b=6356751.8;
x_1=0;
y_1=p;
z_1=0;

for i=451:550
    for j=451:550
    alpha=(1145-i)*degree;
    beta=(1145-j)*degree;

    x_2=p/cos(alpha)*tan(beta);
    y_2=0;
    z_2=p*tan(alpha);

    syms x y z x_1 x_2 y_1 y_2 z_1 z_2 a b
    eq = [(x-x_1)*(y2-y_1)-(x_2-x_1)*(y-y_1),(x-x_1)*(z_2-z_1)-(x_2-x_1)*(z-z_1), b^2*(x^2+y^2)+a^2*(y^2)-a^2*b^2 ]; 
    sol = solve(eq(1),x,eq(2),y, eq(3),z); 
    sol.x
    sol.y
    sol.z        
   end
end

I got the expression value, how do I get the numeric value of x,y,z?

[['x(1)=';'x(2)='],num2str(double(sol.x))]

not work ,shows
??? 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 ==> f2 at 38
[[‘x(1)=’;’x(2)=’],num2str(double(sol.x))]

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:09:45+00:00Added an answer on June 11, 2026 at 10:09 pm

    If you have access to the Symbolic Toolkit then you do the following:

    syms a b k
    eq = [k+a/2-173*cos(b), sqrt(3)*a/2-173*sin(b)];
    sol = solve(eq(1),a,eq(2),b);
    
    sol.a = simplify(sol.a);
    sol.b = simplify(sol.b);
    
    % There are two solutions for 'a' and 'b'
    % check residuals for example k=20
    
    subs(subs(eq,{a,b},{sol.a(1),sol.b(1)}),k,20)
    % ans = 0.2e-13
    
    subs(subs(eq,{a,b},{sol.a(2),sol.b(2)}),k,20)
    % ans = 0.2e-13
    

    Edit 1

    Based on new code by OP the matlab script to solve this is:

    clear all
    clc
    syms alpha beta
    degree=140/1000000;
    p=42164000;
    a=6378136.5;
    b=6356751.8;
    x_1=0;
    y_1=p;
    z_1=0;
    x_2 = p/cos(alpha)*tan(beta);
    y_2 = 0;
    z_2 = p*tan(alpha);
    syms x y z
    
    eq = [(x-x_1)*(y_2-y_1)-(x_2-x_1)*(y-y_1);...
        (x-x_1)*(z_2-z_1)-(x_2-x_1)*(z-z_1); ...
        b^2*(x^2+y^2)+a^2*(y^2)-a^2*b^2 ];
    
    sol = solve(eq(1),x,eq(2),y,eq(3),z);
    sol.x  = simplify(sol.x);
    sol.y  = simplify(sol.y);
    sol.z  = simplify(sol.z);
    pt_1 = [sol.x(1);sol.y(1);sol.z(1)]    % First Solution Point
    pt_2 = [sol.x(2);sol.y(2);sol.z(2)]    % Second Solution Point
    x = zeros(100,100);
    y = zeros(100,100);
    z = zeros(100,100);
    for i=451:550
        disp(['i=',num2str(i)])
        for j=451:550        
            res = double(subs(pt_1,{alpha,beta},{(1145-i)*degree,(1145-j)*degree}));
            x(i-450, j-450) = res(1);
            y(i-450, j-450) = res(2);
            z(i-450, j-450) = res(3);
        end
    end
    disp('x=');
    disp(x);
    disp('y=');
    disp(x);
    disp('z=');
    disp(x);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to solve two nonlinear equations in MATLAB so i did the following:
I'm using Matlab to solve a differential equation. I want to force ode45 to
I want to solve a system of n linear equations containing n variables using
What algorithm would you make a computer use, if you want to solve a
here i want to solve stack overflow issue in this code. here in this
I would like to solve the linear system Ax = b in a linear
I'm trying to code a program that solves systems of equations in MATLAB. I
I would like to solve an equation as below, where the X is the
I want to solve a differential equation lots of times for different parameters. It
I want to solve the following optimization problem: Non-Latex: Given x and mu, find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.