Problem with solving multivariable trigonometric equations

3 visualizaciones (últimos 30 días)
Minerva Bionic
Minerva Bionic el 30 de Sept. de 2021
Editada: Minerva Bionic el 30 de Sept. de 2021
Hi everyone,
I have no idea where is wrong in my code?
clear all;
%%
clc
Fs = 1e6;
f = 5;
t = 2e6;
ang0 = t*2*pi*f/Fs
ang0 = 62.8319
dang = 1*2*pi*f/Fs
dang = 3.1416e-05
y0= 1*sin(t*2*pi*f/Fs);
y1= 1*sin((t+1)*2*pi*f/Fs);
y2= 1*sin((t+2)*2*pi*f/Fs);
% for i = 1:10e6
% Curve(i) = 1*sin(i*2*pi*f/Fs);
% end
%
% close all
% hold on
% plot(Curve)
%%
syms x y z
% assume(x > 0)
% assumeAlso(x < 1)
% assume(z >= 0)
% assumeAlso(z <= 2*pi)
% assume(y > 0)
% assumeAlso(y <= 100)
[x,y,z]=solve(x*sin((t*2*pi*y/Fs) + z)==y0 ,x*sin(((t+1)*2*pi*y/Fs)+z)==y1,x*sin(((t+2)*2*pi*y/Fs)+z)==y2,'ReturnConditions',true)
x = Empty sym: 0-by-1 y = Empty sym: 1-by-0 z = Empty sym: 0-by-1

Respuesta aceptada

Matt J
Matt J el 30 de Sept. de 2021
Editada: Matt J el 30 de Sept. de 2021
In order for solve() to find a solution, an exact analytical solution must exist.
  9 comentarios
Minerva Bionic
Minerva Bionic el 30 de Sept. de 2021
Editada: Minerva Bionic el 30 de Sept. de 2021
I know "least square nonlinear" and vpasolve methods are great in solving equations. But since I'm curious about another possible methods, I thought it would be fine if I ask you for other possible methods.
Minerva Bionic
Minerva Bionic el 30 de Sept. de 2021
Editada: Minerva Bionic el 30 de Sept. de 2021
As I realized I should provide arrays of data for x, y, z for lsqnonlin method.
The solve method can return symbolic solutions. Since I want to implement the solution in a hardware, solve method is the best method in my case.
However, I still have problem with numerical vpasolve() method
clear all
clc
Fs = 1e6;
f = 5;
t = 2e6;
y0= 1*sin(t*2*pi*f/Fs);
y1= 1*sin((t+1)*2*pi*f/Fs);
y2= 1*sin((t+2)*2*pi*f/Fs);
% Available information for solving equations: y0,y1,y2, Fs, t
% Answers: x=1 , y=5, z=0
syms x y z
[x,y,z]=vpasolve(x*sin((t*2*pi*y/Fs) + z)==y0 ,...
x*sin(((t+1)*2*pi*y/Fs)+z)==y1 , ...
x*sin(((t+2)*2*pi*y/Fs)+z)==y2,[x y z],[0 1.2; 0 10; -pi pi])
x = 
0.82808197968524438542250921861996
y = 
6.0380495220795251235306856358895
z = 
%% Acceptable answers by reducing variables
clc
syms x z
y= 5;
[x,z] = vpasolve(x*sin((t*2*pi*y/Fs) + z)==y0 ,...
x*sin(((t+1)*2*pi*y/Fs)+z)==y1,[x z],[0 1.2; -pi pi])
x = 
1.0000000003041361573960955992907
z = 

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Function Creation en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by