Solve for array of values for cos and sin functions returning [0x1 sym]
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Dylan Gannan
il 24 Giu 2019
Commentato: infinity
il 24 Giu 2019
Hello,
I am having problems with using an array in a cosine function, I have replicated the problem in a much simpler example code:
clear all
c = 1:1:10;
syms x y
a = x^2 + sind(c) -y == 3;
b = x - cosd(c) +y ==5;
solve([a b], [x y])
ans =
struct with fields:
x: [0×1 sym]
y: [0×1 sym]
I am expecting this to return an array of each iteration of sind(c), or some way of doing so, but instead I just get nothing at all.
I thought I had my head around Matlab but this one has stumped me, also I'm a first time user of Matlab forums so I hope the formatting has come out OK, I googled how and just found posts about how annoying it is explaining to forum newbies to format your code :P
3 Commenti
Risposta accettata
Alex Mcaulley
il 24 Giu 2019
One way:
syms x y c
a = x^2 + c - y == 3; % function a is overwritten in the next line!
a = x^2 + sin(c*pi/180) - y == 3; %c in degrees
b = x - cos(c*pi/180) + y == 5;
res = solve([a b], [x y]);
resx = double(subs(res.x,c,1:1:10));
resy = double(subs(res.y,c,1:1:10));
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Function Creation in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!