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 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Function Creation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!