COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### adding up values from multiple plots

• Email
• Follow

```Hello,
Is there anyway i can add up up all the values from multiple discrete function plots without going through all them and looking at all of their values and manually adding them.
```
 0
Reply garlicenator (1) 10/14/2008 4:29:02 AM

See related articles to this posting

```"john geo" <garlicenator@gmail.com> wrote in message <gd176e\$rgs\$1@fred.mathworks.com>...

> Is there anyway i can add up up all the values from
> multiple discrete function plots without going through all
> them and looking at all of their values and manually

Lines = findobj(0, 'Type', 'line');
nLines = length(Lines);
Xvals = cell(nLines,1);
Yvals = cell(nLines,1);
for K=1:nLines
Xvals{K} = get(Lines(K),'XData');
Yvals{K} = get(Lines(K),'YData');
end

AllX = unique(reshape( cell2mat(Xvals), [], 1));
numX = length(AllX);
Ysum = zeros(numX, 1);

for K = 1:nLines
TheseY = interp(xvals{K}, yvals{K}, Allx);
Ysum = Ysum + TheseY;
end

End result: a vector AllX of all the different X values
over all of the plots, and a vector Ysum of the sums of
all of the Y values that would be interpolated at those
different X values.

Caution: if one plot has an X point at (say) 1.5
exactly, and another plot has an X point that is
intended to be the same, but due to a different
calculation route comes out as 1.5+eps(1.5), then
the unique() step will believe them to be different
points, and so will produce an output for 1.5 and
another output for 1.5+eps(1.5) . This can be handled
(if it is not desired) by refining the unique() step of
the algorithm.

The code can be simplified if it is -certain- that
all of the X values are intended to represent the same
points on all of the graphs, and simplified considerably
further if it is -certain- that there are also exactly
the same number of X/Y pairs for each of the graphs.
As written, the code does not assume that the graphs
have the same X axes nor the same number of points per
graph.
```
 0
Reply roberson2 (8606) 10/14/2008 5:28:01 AM

1 Replies
102 Views

Similar Articles

12/12/2013 7:13:28 AM
[PageSpeed]

Similar Artilces:

How do you plot multiple plots in an array with no space between plots?
I have some data that I'd like to plot in 12 small square plots, and then arrange those 12 plots into a 4x3 rectangular array. The thing I'd like to do that I don't know how to do is simplify the 4x3 rectangular array by squeezing the plots together, such that there is no space between the plots: the right-hand border of a plot should be coincident with the left-hand border of the plot to its right, and its lower border should be coincident with the upper border of the plot right below it. Imagine 12 squares on a checkerboard; that's what I'm aiming for. As far as I ca...

how to get multiple=multiple values from an optgroup ?
hey there all, i have an html page that uses a select element with optgroups. I want multiple="multiple" but when i pass it to the php script, i do not know how to get the values out. like this <select name="people" multiple="multiple" > when this is submitted, are they passed as an array? thanks "nephish" <nephish@gmail.com> wrote in message news:1160764737.443297.251860@h48g2000cwc.googlegroups.com... > hey there all, > > i have an html page that uses a select element with optgroups. I want > multiple="multiple&quo...

Adding a scatter plot to a contour plot
I have a contour plot of X, Y, Z where X and Y are 5 x 1 matrices. I would like to add a scatter plot of X and Y to the contour plot. Can someone please tell me how to add a scatter plot to the existing contour plot? Thank you. RRS wrote: > > > I have a contour plot of X, Y, Z where X and Y are 5 x 1 matrices. > I > would like to add a scatter plot of X and Y to the contour plot. > Can > someone please tell me how to add a scatter plot to the existing > contour plot? Thank you. try: contour(x,y,z); hold on scatter(x,y); hold off ...

plotting an array values keeping origin as a reference value
Hi all, I have an array a=[4,2,6,9,3,1]. I wan to plot these array values from origin, like (0,4),(0,2),(0,6) etc. How to plot this. shambhu writes: > I have an array a=[4,2,6,9,3,1]. I wan to plot these array values from > origin, like (0,4),(0,2),(0,6) etc. How to plot this. I would do it like this: a=[4,2,6,9,3,1] b = Indgen(N_Elements(a))+ 1 cgplot, b, a, /NoData, XRange=[0,Max(b)+1], XStyle=1 FOR j=0,N_Elements(a)-1 DO BEGIN cgPlotS, [b[j],b[j]], [a[j],!Y.CRange[0]], Color='red', Thick=2 ENDFOR END Cheers, David -- David Fanning, Ph.D. Fa...

multiple plots
&nbsp; Hello, &nbsp; I wish to plot multiple&nbsp;&nbsp;traces (up to 8) on the same chart. I think my code is ok&nbsp;though I'd like to know if there's a better way than I chose. I also need to know that I have used the array control correctly. &nbsp; Thank you. multiple plot.vi: http://forums.ni.com/attachments/ni/170/239979/1/multiple plot.vi &nbsp; Dear All, Clearly I'm not very capable at all. I've incorporated the VI above into the main VI&nbsp;(I could have put it in as a sub VI but I prefered not to); it can be found in the "Aqui...

Multiple Plots!?!?!?
Once again I am new at this and thanks for all of the help! My question is if someone could help me figure out how to produce multiple plots. Each time I use the comand plot(whatever); it plots over the plot I had made in the program prior. How would I, for instance, make 5 plots that are each present at the end of a program? i.e. plot(a) plot(b) plot(c) and so on...?? Any help with this would be wonderful! Thanks Jay Hi Jav, help hold Titus "J S" <saidar1@hotmail.com> schrieb im Newsbeitrag news:ef0b3e7.-1@webx.raydaftYaTP... > Once again I am new at this and than...

map with multiple values
Hi, Suppose I have a vector, and I want to apply a function that returns multiple values to each element and get the result as a matrix. Eg a hypothetical (map-values #'round #(1.4 1.7) would return #2A((1 0.4) (2 -0.3)) (errors in floating point arithmetic disregarded). My messy solution currently uses multiple-value-list to capture the returned values as a list, then extract elements from this list, which are copied to rows of a matrix. I wonder if there is something more elegant. Thanks, Tamas On 13 oct, 21:32, Tamas Papp <tkp...@gmail.com> wrote: > Hi, > > Sup...

hello, hope i am posting this in the right group. i need to add multiple values (by scanning a barcode for example - or even entering it manually). i also want a separate area (possibly a list box or text area to be more precise) where i can see the items in a list before i submit the details for processing. please note that if i am scanning multiple items, i can scan multiple items (one after the other) and have the last character as a CR/LF; however i dont know how I would separate two (or more) items scanned (possibly by a comma or new line feed). how do i achieve this and is there a b...

multiple plots in same figure
Hi NG, I need to plot several time-series in the same window, which is easily done with "hold on".. But here's the catch: I would like to shift them in the Y-direction, so that they do not appear on top of each other.. The application is to have a number of time-traces plotted beside each other so wiggles in the plots can be traced across the figure by eye.. Is this making sense? The only solution I can come up with myself is to actually add an increasing offset value to the Y-values of the plots, thus shifting them, but I'm not really interested in changing the values of t...

plotting values #2
Hi, I am having a bit of a problem in plotting some values. the code i am working on currently is: for i=[1:1:4] BPK=BPK0(i); p=p0(i); Ke=((poles/2)*N*A*BPK*w); %peak amplitude of back emf const=(24.*Ke.*w)/(pi^2); R=p*(2*a+2*h*N)/(a*c); %Resistance of a lamination for n=[1 3 5 7 11] theta=n*pi/6; fs=(1/n)*((((1/n)*sin(n*5*pi/6))+ cos(n*5*pi/6))*sin(n*theta)); dB=(const.^2) *(fs.^2); emf=(h*a/N)*(dB); emfsq=emf.^2; P_eddy=(emfsq)./R; I would like to plot for when n=1 for a value of BPK0(1), the ...

In my form I have it bringing up record information from 2 differant tables and that works just fine. The problem is when I try to add a new set of information it only adds the key to the one table and not the other. wpvnetx@hotmail.com wrote: > In my form I have it bringing up record information from 2 differant > tables and that works just fine. The problem is when I try to add a > new set of information it only adds the key to the one table and not > the other. > I'll assume this is a one-to-one link, not using a subform. Let's say the field is ID in both. Ma...

catching multiple values
Hi, I am writing a wrapper function to C code (still cairo ;-), where error status needs to be queried explicitly. The following self-contained code demonstrates what I am trying to do: (defun query-status () 'success) (defmacro catch-error (&body body) (let ((result (gensym)) (status (gensym))) `(let* ((,result (progn ,@body)) (,status (query-status))) (if (eq ,status 'success) ,result (warn "status is ~a" ,status))))) Now the fly in the ointment: it works fine if body returns a single value: (catch-error (+ 1 1)) but not so with multi...

Plotting values in boxes
Hi, I have a 6x9 matrix and I want to plot the values so that there are 54 squares and each has its corresponding value. I have used the contourf function but as expected it doesn't come out correctly. I'm not sure if there is a graphic function that will do this? Thanks for any help, Dave "David " <sum_is_41@hotmail.com> wrote in message <jj7j7u\$nqj\$1@newscl01ah.mathworks.com>... > Hi, > > I have a 6x9 matrix and I want to plot the values so that there are 54 squares and each has its corresponding value. > I have used the contourf function but as ...

Multiple plotting windows?
Hello all: First of I would like to say that I really like the tone of this group. I've been reading this group and a group on Mandrake Linux for a few weeks now, and boy is there a difference. Please keep up the good work. Now to my question. Say I plot a data set via the usual methods, i.e. plot, values.solar[*,0], values.solar[*,1], blah blah blah. Then window pops up with the plot and the title "IDL 0" in the title bar. What I can't figure out is how to plot a new data set in a new window, which leaves the original window undisturbed. There seems like there should be a ...

Adding a legend to the plot
Howdy Folks, So I have a dilemma; I will condense the issue here, so that it may be easier to digest the question. Let's assume that my data consists of 3 points. Just for giggles, assume that they are at points [10, 2], [15, 3] and [20,4]. How can I give unique colors to the data that I want. Instead of saying legend('data1','data2','data3'), my goal is to uniquely identify the colors within the legend. For example, the following code works fine, but it uses the "legend's" reference to data points. R=[1 0 0]; G=[0 1 0]; B=[0 0 1];...

optimized values plot
How can we plot the optimized values against iterations? ...