Finding the mean along X axis on plot?

4 ビュー (過去 30 日間)
bio lim
bio lim 2015 年 7 月 3 日
コメント済み: Walter Roberson 2015 年 7 月 3 日
Hello. I am trying to find the mean along the X axis as follows.
As shown in the plot, I would like to find the mean of the 'GS-TAS' scatter plots on different altitudes. For example, by drawing a line perpendicular to the Altitude axis on 2.35x10^4 feet, you can see corresponding GS-TAS values. I would like to find the mean of those values, on all altitude levels then plot it against the altitude. Is it possible? Any simple methods to do it? Thanks.

採用された回答

Walter Roberson
Walter Roberson 2015 年 7 月 3 日
level_spacing = 500;
Alt = .... %vector of the altitudes of each data point
GSTAS = ... %vector of the GS-TAS for each data point
altbins = 1 + floor(Alt(:) ./ level_spacing); %convert altitude to relative level number
mean_gstas = accumarray(altbins, GSTAS(:), [], @mean, NaN); %all the real work
altlevels = level_spacing * (0:length(mean_gstas)-1);
plot(altlevels, mean_gstas, '*-');
With this code, any altitude level for which there is no data will not show a connecting line; no interpolation is implied. If you want connecting lines then change the plot() to
hasdata = ~isnan(mean_gstas);
plot(altlevels(hasdata), mean_gstas(hasdata), '*-');
  3 件のコメント
Hugo
Hugo 2015 年 7 月 3 日
編集済み: Hugo 2015 年 7 月 3 日
Hi coffee You can get the vectors that the answer of Walter require as follows. For example, in the case of the altitude, do this:
Alt = cell2mat(arrayfun(@(x)data2(x).altitude',1:numel(data2),'UniformOutput',false));
This certainly looks overly complicated for a reason: The data in your fields are column vectors. Should they be row vectors, you could have obtained the same by doing this:
Alt = [data2.altitude];
Hope this helps. Hugo
Walter Roberson
Walter Roberson 2015 年 7 月 3 日
Alt = vertcat(data2.altitude);
should do fine with column vectors.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by