Plot function with time step

조회 수: 18 (최근 30일)
Niklas Kurz
Niklas Kurz 2020년 6월 4일
편집: Niklas Kurz 2020년 6월 5일
Hello, even if this question was posed in a similar way, I couldn't apply it to my issue, also given the fact I'm very new.
However, I got a set of values (.txt format: A= 4063x1). Thus the y-values are provided, I'd name them y = A{:,1}; Unfortunaly x values are missing, it's just being said time step = 0.000999. That's what is bothering me: how am I generating my line of x-values? It'd be most kind if you'd solve that trivial thing for me. Thx in advance.

채택된 답변

David Hill
David Hill 2020년 6월 4일
I assume x is time then corresponding to your y-values with the given step starting at zero.
x=0:.000999:4.057938;
  댓글 수: 1
Niklas Kurz
Niklas Kurz 2020년 6월 5일
Thank you so much! (btw. for those who are facing the same problem: last number (4.057938) represents the product of 4062 times 0.000999 to match x and y values)

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

추가 답변 (1개)

Steven Lord
Steven Lord 2020년 6월 5일
A slightly different way to create that vector would be to compute integer multiples of the spacing. First I'll make some sample Y data of the correct size:
y = rand(4063, 1);
Now build x.
timestep = 0.000999;
x = (0:numel(y)-1)*timestep;
  댓글 수: 1
Niklas Kurz
Niklas Kurz 2020년 6월 5일
편집: Niklas Kurz 2020년 6월 5일
Thank you for your answere as well. Maybe you happen to answere me an additional simple question: If I just want certain rows of my table to be chosen, how to achieve this? By typing y = A{:, 1}; Matlab picks all 4063 values. Pretending I just want to evaluate 2014-4063, what to do?

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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by