Solve for array of values for cos and sin functions returning [0x1 sym]

14 次查看(过去 30 天)
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 个评论
Dylan Gannan
Dylan Gannan 2019-6-24
I have edited it, cheers.
My question is how do I solve for each array value so that I can plot its output.
I am plotting the position of a link in a walking robot mechanism for a 360 degree rotation of it's crank. So one of my theta values is going to have 1:1:360. I made that question above to simplify and define my error.

请先登录,再进行评论。

采纳的回答

Alex Mcaulley
Alex Mcaulley 2019-6-24
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 个)

类别

Help CenterFile Exchange 中查找有关 Function Creation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by