# Thread Subject: Fitting to match pre-specified means

 Subject: Fitting to match pre-specified means From: james bejon Date: 21 Feb, 2012 11:40:12 Message: 1 of 2 Dear All, This probably has as much to do with maths and the like as with Matlab. But I'm not so great in either department, so figured I might be able to get some help from someoneā¦ % Suppose I have the following 'bands' and 'vals': bands = [0 50 75 90 95 100 110 125 200]; vals = [20 120 110 60 40 20 10 5]; meanperband = vals ./ (bands(2:end) - bands(1:end-1)); % I can then break this aggregate data down into individual 'integer bands' like this: [~, ints] = histc((0:bands(end)-1), bands); res = [ints.', meanperband(ints).']; % I can then get back to my starting values like this: accumarray(res(:, 1), res(:, 2)) The question is, Is there anything I can do to give my breakdown a more realistic "shape"--even if I just end up connecting points with straight lines. (Sorry, I can't think of a better way of putting it). Basically, I'm assuming that, within each band, every integer band has the same value. But I don't really want to. My starting 'vals' will suggest a kind of shape which I'm not capturing. Does this make any sense?
 Subject: Fitting to match pre-specified means From: Tom Lane Date: 22 Feb, 2012 15:16:44 Message: 2 of 2 > The question is, Is there anything I can do to give my breakdown a more > realistic "shape"--even if I just end up connecting points with straight > lines. (Sorry, I can't think of a better way of putting it). Basically, > I'm assuming that, within each band, every integer band has the same > value. But I don't really want to. My starting 'vals' will suggest a > kind of shape which I'm not capturing. Does this make any sense? I can't say that I completely understand this, but is this the kind of thing you want? xx = linspace(50,200); plot(bands(2:end),vals,'b-',xx,pchip(bands(2:end),vals,xx),'r-') -- Tom

### Everyone's Tags:

Separated by commas
Ex.: root locus, bode

### What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.