How can I send my radian values to a function?
Show older comments
Hello, Im trying to send my q values to a function. q values is changing from 0 to 2pi. The function is for taking derivative of ra for each q values. And then I have to plot a graph derivative values for each q values(y axis) - q values as degrees(x axis). I dont know what is problem is. Function code;
function [ dra ] = Derivative( x )
a=0.016489;
b=0.015;
c=0.027;
d=0.075;
h=0.010;
x1=(a*c*sin(x)-h*c+b*d+a*b*cos(x))/(d-c+a*cos(x));
theta=atan((x1-b)/c);
x3=sqrt((d.^2)+(a.^2)+(x1.^2)-2*x1*h+(h.^2)+2*(x1-h)*a*sin(x));
ra=a*exp(j*x)-x3*exp(j*theta);
dra=diff(ra,x)
end
Main program;
clear all
clc
m=0:(pi/18):(2*pi);
m=m.'
n=length(m);
ddata=zeros(n,1);
for i=1:n
q = (i-1)*(pi/18);
[f] = Derivative(q)
data(i)=f(q);
end
disp(data)
degrees=m*(180/pi);
plot(degrees,data)
xlabel('Angle');
ylabel('Velocity of Point A');
title('Velocity Graph')
I have these errors when I run the code.
Error using diff Difference order N must be a positive integer scalar.
Error in Derivative (line 12) dra=diff(ra,x)
Error in deneme2 (line 12) [f] = Derivative(q) Thanks,
Accepted Answer
More Answers (0)
Categories
Find more on Graphics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!