How to use while loop and if statements to create an interval

I had a data with multiple same year values. I wanted to use while loop and if statments and create a small intervals that can alter the values so that they can be distinct for plotting. Any pointers?

3 Comments

Why a loop and if statements? Just add a random noise element to each value--how much "jitter" do you want? Or, if you want them offset by regular amounts, just create a set of delta-t values from [-N/2:N/2]*dt and add to each set....this would be simplest if were the same number of duplicated values for each date because could then rearrange by that number and do global addition by automagic unit expansion.
It is a problem with twleve same year values on the x axis and i wanted to differentiate these values from eachother by a small value.
Yes. What do you consider "a small value"?
What is the format for the x data--are they just doubles holding the year or a datetime variable or what? It's always SO much easier if you'll show us instead of making us guess what we're talking about.
Lastly, still, why a loop and if -- what's wrong with the suggestions made above?

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 8 Nov 2019

Commented:

dpb
on 8 Nov 2019

Community Treasure Hunt

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

Start Hunting!