필터 지우기
필터 지우기

How to plot x y data with y value repeating with a given interval while x continously increasing?

조회 수: 1 (최근 30일)
I have actual x and y data for a length of 8193, i.e Z=[(X1,Y1) (X2,Y2)....(X8193,Y8193)] . I want to plot (xn,yn) for n size of data pairs with repeating the y value after each 8193 interval while the x continuously increment with one for each data. thanks
  댓글 수: 1
seble mekonnen
seble mekonnen 2018년 1월 25일
sir, I have tried with small size number (to repeat after multiple of 9 for 100 data sets. But still I have not get it. 1. how each x(i)and y(i) value gets its value. I expect a triangular shape with touching x at 1 9 18 29 etc thanks
y=[1 2 3 4 5 4 3 2 1]
x=[1 2 3 4 5 6 7 8 9]
xn=ones(1,100);
j = 1;
for i = 1:length(xn)
if(j==10)
j = 1;
end
if i<=5
y(i)=i;
else
y(i)=y(5)-y(i-5);
end
j = j+1;
plot(x(i), y(j));
end
error
Index exceeds matrix dimensions.

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

답변 (1개)

Srijith Vijay
Srijith Vijay 2018년 1월 25일
j = 1;
for i = 1:n
if(j==8194)
j = 1;
end
plot(x(i), y(j));
j = j+1;
end
  댓글 수: 2
seble mekonnen
seble mekonnen 2018년 1월 25일
sir, I have tried with small size number (to repeat after multiple of 9 for 100 data sets. But still I have not get it. 1. how each x(i)and y(i) value gets its value. I expect a triangular shape with teouching x at 1 9 18 29 etc thanks
y=[1 2 3 4 5 4 3 2 1]
x=[1 2 3 4 5 6 7 8 9]
xn=ones(1,100);
j = 1;
for i = 1:length(xn)
if(j==10)
j = 1;
end
if i<=5
y(i)=i;
else
y(i)=y(5)-y(i-5);
end
j = j+1;
plot(x(i), y(j));
end
error
Index exceeds matrix dimensions.
Srijith Vijay
Srijith Vijay 2018년 1월 26일
In your code snippet, the value of index i exceeds the size of y and y(i) = y(5)-y(i-5) tries to access the value of y outside its bounds.
You can make use of the "repmat" function to create the vector y based on the number of samples to plot.

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by