|
|
adding up values from multiple plots
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.
thx in advance.
|
|
0
|
|
|
|
Reply
|
garlicenator (1)
|
10/14/2008 4:29:02 AM |
|
"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
> adding them.
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 (8067)
|
10/14/2008 5:28:01 AM
|
|
|
1 Replies
76 Views
(page loaded in 0.009 seconds)
Similiar Articles: Plotting multiple variables generated from a loop in the same ...I have set up the loop so that the data is generated like this Freq (fixed value for X axis) TL_1 (an array ... Plotting multiple plots on the same graph - comp.soft ... Multiple line plots, two y axes - comp.soft-sys.matlab... This was an issue I actually gave up on ... not understand why MATLAB could not add a y-axis (ie. right or left) with plot. ... I plot multiple data series and use plotyy to ... Add points on Bode plot - comp.soft-sys.matlab... problem : I've got pairs of values (frequency,amplitude) and (frequency,phase). I would like to add them the same way on a bode plot. ... the whole thing? That doesn't add up Reverse the scale in Mathematica plot - comp.soft-sys.math ...3) It would be easy to add other curves and primitives to the graphic. You ... Multiple line plots, two y axes - comp.soft-sys.matlab... are for a common time period, but ... how to import data from multiple text files? - comp.soft-sys ...... have 500+ text files, each storing an integer value ... me few hours searching through the internet end up ... comp.lang.java.gui ... how to import data from multiple text ... add zero cells to matrix - comp.soft-sys.matlabAdd values to an array - comp.soft-sys.matlab add ... matrix - comp.soft-sys.matlab Adding up cell array elements - comp.soft-sys.matlab Unpacking a cell array into multiple ... How to shift the values of x axis from position of x axis to other ...Hi, I am having a plot, with xaxis varies from 0 to 1023(pixels) and yaxis varies from 5000 to 7000(intensity), likewise i am having 21 plots, ... Merging of plots / figures - comp.soft-sys.matlab... various figures / > plots and generate one single plot ... you might want to start by dividing the new figure up ... Combine multiple figures (.fig) with subplots into one ... Working with multiple GUI - subplot - comp.soft-sys.matlab ...Adding a title to plots with subplots - comp.soft-sys.matlab ... ... soft-sys ..... but when at standard "pop-up ... in a GUIDE-generated GUI, see Displaying Multiple Plots ... Multiple Line Text in GUI Axes - comp.soft-sys.matlab... or string variable as the axes' string value and do this, or do I have to manually break up ... plots in the GUI figure. ... Design the Multiple Axes GUI. This GUI plots ... Figure Setup :: Basic Plotting Commands (MATLABĀ®)Displaying multiple plots per figure, targeting a specific axes ... Set Up the Close Confirmation Dialog Set Up the ... edge colors to black, and defines appropriate values ... Multiple series with different x-values on one scatter plotI'm trying to add a new series to a scatter plot in Excel, but the new series uses a different set of x-values. I want to plot it along the same axis as the other ... 7/23/2012 12:26:01 PM
|
|
|
|
|
|
|
|
|