Use Plot as function

조회 수: 3 (최근 30일)
Marco Poppe
Marco Poppe 2019년 1월 8일
댓글: Sayyed Ahmad Fani Yazdi 2019년 1월 15일
Hey People,
im trying to implement a multiple live plot function for my data. Instead of long description, here some code for understanding:
Main:
while plotting == true
for i=0:0.05:10
x = sin(i);
Input.Value(1,1) = i;
Input.Value(1,2) = x;
y = cos(i);
Input.Value(2,1) = i;
Input.Value(2,2) = y;
plotting = Liveplot(Input);
end
end
and the Liveplot function:
function [Running] = Liveplot(Input)
for i=1:size(Input.Value,1)
figure(i);
hold on;
plot(Input.Value(i,1),Input.Value(i,2));
drawnow;
hold off;
end
end
(sure some code between is missing, hope you understand my thinking)
I want a line between my parameters - a graph, interpolation, ... and not only points at the plot (see image below)
If i dont tell my plot to make '+', i dont see any points at the plot.
How can i see my graph of the datapoints (the line between)?
(at picture both functions in one plot...)
Unbenannt.PNG

답변 (2개)

madhan ravi
madhan ravi 2019년 1월 8일
  댓글 수: 2
Marco Poppe
Marco Poppe 2019년 1월 11일
Can you give me some example code? I dont get this ..
madhan ravi
madhan ravi 2019년 1월 11일

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


Sayyed Ahmad Fani Yazdi
Sayyed Ahmad Fani Yazdi 2019년 1월 14일
편집: Sayyed Ahmad Fani Yazdi 2019년 1월 14일
if you change your code to the following code
clear all
close all
clc
count=1
In.Value(1,1) = 0;
In.Value(2,1) = 0;
for i=0:2*pi/100:2*pi
x = sin(i);
y = cos(i);
In1.Value(1,count) = i;
In1.Value(2,count) = x;
In2.Value(1,count) = i;
In2.Value(2,count) = y;
count=count+1
end
Liveplot(In1)
hold on
Liveplot(In2)
and overload your plot function like this.
function Liveplot(In)
plot(In.Value(1,:),In.Value(2,:),'b-')
end
  댓글 수: 2
Marco Poppe
Marco Poppe 2019년 1월 15일
Then i dont have the option to see my plot in time while simulating. Im trying to write a liveplot function
Sayyed Ahmad Fani Yazdi
Sayyed Ahmad Fani Yazdi 2019년 1월 15일
change in your liveplot function
plot(Input.Value(i-1:1,1),Input.Value(i-1:i,2),'-b');
so your code create a line and not a point.

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

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by