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

9 ビュー (過去 30 日間)
Dylan Gannan
Dylan Gannan 2019 年 6 月 24 日
コメント済み: infinity 2019 年 6 月 24 日
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.
infinity
infinity 2019 年 6 月 24 日
Have you tried @Alex Mcaulley's solution?

サインインしてコメントする。

採用された回答

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 Center および File ExchangeFunction Creation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by