# How to plot outputs from an equation with user inputs?

16 views (last 30 days)
Bastion on 29 Aug 2011
Answered: Mohit Sharma on 1 Oct 2016
I'm trying to plot a graph (xy-plot) in MATLAB GUI. I have coded an equation along with input boxes for user inputs (the variables). So after the user input the many variables the program will calculate the answers. I have time 1 and time 2 as a range for the plot in the x-drection. Now I want to code it so it will plot all the points between time 1 and time 2.
##### 2 CommentsShowHide 1 older comment
Bastion on 29 Aug 2011
Yeah it's gone

Paulo Silva on 29 Aug 2011
Oleg already gave you all the clues you need
T1=1;T2=10;NPoints=5;
u=10;v=20;w=1; %some inputs to your formula
t=linspace(T1,T2,NPoints);
plot(t,c,'*') %just the points
%plot(t,c) %line joining the points
%plot(t,c,'r*');hold on;plot(t,c); hold off %points and line
Bastion on 31 Aug 2011
Thanx I get it now

Oleg Komarov on 29 Aug 2011
Let's say you have these two ranges:
time1 = now-9;
time2 = now;
% And you want to create 100 equispaced points on the range [time1 time2]
x = linspace(time1,time2,100);
y = f(x);
where f() is the equation you have coded, then plot:
plot(x,y)
If you don't what a specific function does, use the help or type in the command window:
doc functionName
##### 2 CommentsShowHide 1 older comment
Bastion on 31 Aug 2011

Mohit Sharma on 1 Oct 2016
sir please tell me that how to take input(Equation with range) from user and plot graph....