How to plot outputs from an equation with user inputs?

조회 수: 4 (최근 30일)
Bastion
Bastion 2011년 8월 29일
답변: Mohit Sharma 2016년 10월 1일
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.
What is the best way to go about this in GUI?
  댓글 수: 2
Oleg Komarov
Oleg Komarov 2011년 8월 29일
Please delete your previous question since this duplicate it's better phrased.
Bastion
Bastion 2011년 8월 29일
Yeah it's gone

댓글을 달려면 로그인하십시오.

채택된 답변

Paulo Silva
Paulo Silva 2011년 8월 29일
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);
c=u*t+v*(t/10)+w*t.^2; %your concentration formula, I made it up
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

추가 답변 (2개)

Oleg Komarov
Oleg Komarov 2011년 8월 29일
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
Bastion
Bastion 2011년 8월 29일
I don't know how to word this but I'm trying to plot concentration to time, which is my output as a range in the y-direction.
C(x,y,z,t) etc.
t (time) is a function of C. When I input 2 values for t, I wrote the code so it would display 2 output for the C range. So if I input T1=1 and T2=10 I will get C1=X and C2=Y. I want to plot this two ranges with a set amount of points.
Bastion
Bastion 2011년 8월 31일
Thanx for the reply

댓글을 달려면 로그인하십시오.


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

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by