MATLAB: Function return multiple variables

matlab functionreturn

My question is very simple, my function has values for x,y,t but only displays values for x. I want the values of y and t to also be returned.
function [x, y, t] = IVP(c)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
syms x y h t;
h=c;
x=zeros(1,30);
y=zeros(1,30);
u=[2;1];
t=[0:1:29];
for i=2:1:30
x(1)=2;
y(1)=1;
x(i)=u(1)+h*(1.2*u(1)-0.6*u(1)*u(2));
y(i)=u(2)+h*(0.3*u(1)*u(2)-0.8*u(2));
u(1)=x(i);
u(2)=y(i);
end
plot(t,x,'b',t,y,'k');
xlabel('time') % x-axis label
ylabel('Population of Prey and Predator') % y-axis label
legend('x(t)-prey','y(t)-predator')
end

Best Answer

Call the function like this
[x, y, t] = IVP(c)