plotting this program is causing a problem how to fix it?
Show older comments
clear
k = 1E-3;
[y(4),y(5),y(6)] = meshgrid(-4:0.25:4,-4:0.25:4,-4:0.25:4);
dy(1) = (P - y(1).*((abs(y(4)))^2 +1))./tf;
dy(2) = (P - y(2).*((abs(y(5)))^2 +1))./tf;
dy(3) = (P - y(3).*((abs(y(6)))^2 +1))./tf;
dy(4)= (y(1)-a).*((y(4))./tc) + (k./tc).*(y(5)).*cos(y(7));
dy(5)= (y(2)-a).*((y(5))./tc) + (k./tc).*(y(4)).*cos(y(7)) + (k./tc).*(y(6))*cos(y(8));
dy(6)= (y(3)-a).*((y(6))./tc) + (k./tc).*(y(5)).*cos(y(8));
dy(7) = o(1,1) - (k./tc).*((y(4)./y(5)) + (y(5)./y(4))).*sin(y(7)) + (k./tc).*(y(6)/y(5)).*sin(y(8));
dy(8) = o(1,2) - (k./tc).*((y(5)./y(6)) + (y(6)./y(5))).*sin(y(8)) + (k./tc).*(y(4)/y(5)).*sin(y(7));
r = sqrt((dy(4)).^2 + (dy(5)).^2 + (dy(6)).^2 );
quiver(y(4),y(5),y(6), (dy(4))./r, (dy(5))./r, (dy(6))./r,1/2,'linewidth',1);
hold on;
axisa equal
set(gca,'Fontsize',20)
axis([-4 4 -4 4 -4 4])
while (true)
y0 = ginput(1);
ti = 0;
tf = 1E-2;
tspan=[ti tf];
[T,Y]= ode45(@(t,y) rate_eq(t,y,k),tspan,y0);
plot3(Y(:,4),Y(:,5),Y(:,6));
xlabel("A1");
ylabel("A2");
zlabel("A3");
end
function dy = rate_eq(t,y,k)
dy = zeros(8,1);
P = 0.2;
a = 0.1;
tf = 230E-6;
tc = 30E-9;
o(1,1) = 3E4;
o(1,2) = 4E4;
dy(1) = (P - y(1).*((abs(y(4)))^2 +1))./tf;
dy(2) = (P - y(2).*((abs(y(5)))^2 +1))./tf;
dy(3) = (P - y(3).*((abs(y(6)))^2 +1))./tf;
dy(4)= (y(1)-a).*((y(4))./tc) + (k./tc).*(y(5)).*cos(y(7));
dy(5)= (y(2)-a).*((y(5))./tc) + (k./tc).*(y(4)).*cos(y(7)) + (k./tc).*(y(6))*cos(y(8));
dy(6)= (y(3)-a).*((y(6))./tc) + (k./tc).*(y(5)).*cos(y(8));
dy(7) = o(1,1) - (k./tc).*((y(4)./y(5)) + (y(5)./y(4))).*sin(y(7)) + (k./tc).*(y(6)/y(5)).*sin(y(8));
dy(8) = o(1,2) - (k./tc).*((y(5)./y(6)) + (y(6)./y(5))).*sin(y(8)) + (k./tc).*(y(4)/y(5)).*sin(y(7));
end
% is my algorithm is correct in this? please modify if thereis any possible scenario.
Accepted Answer
More Answers (0)
Categories
Find more on Calculus 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!