How to plot only negative values in a WindRose?

2 次查看(过去 30 天)
I'm working with a function called WindRose.m from Daniel Pereira. https://de.mathworks.com/matlabcentral/fileexchange/47248-wind-rose I'm trying to plot values of atmospheric temperature stability, which can be also negative. I manage to plot all data together and also only the positive values, but I getting an error when I want to plot only the negatives values. And I don't understand what and where I must change the function to get the right plot.
First I tried to modify the signal directly from the function codes here:
speed = speed(speed<0);
When I run the whole code:
% directions
dir=WR;
% speeds
spd=sigma_theta; %specify with values on WindRose.m!
% Positions
Options = {'anglenorth',0,'angleeast',90,'labels',{'N','S','E','W'},'nFreq',5,'FreqLabelAngle',45,'nSpeeds',6,'Min_Radius',0,'TitleString',{'Temp.Stability - Wind rose';''},'LabLegend','Temperatur Stability','LegendVariable','{\sigma\theta}'};
% Windrose plot
[figure_handle,count, speeds, directions]= WindRose(dir,spd,Options);
appears:
Index exceeds matrix dimensions.
Error in WindRose>PivotTableCount (line 383)
counter = histc(speed(cond),[vwinds(:)' Inf]); %# ADDED 2015/Jun/22: Consider the wind speeds greater
than max(vwinds), by adding inf into the histogram count
Error in WindRose (line 304)
count = PivotTableCount(N,n,vwinds,speed,dir,NumberElements); % For each direction and for each speed, value of the
radius that the windorose must reach (Accumulated in speed).
On the second time, I restrict the number of the plot to only my negative values:
i=0;
for j = 1:52705
if sigma_theta(j)<=0
i=i+1;
sigma_theta_copia(i)=sigma_theta(j);
dir_copia(i)= dir(j);
indice(i)=i;
end
end
spd=sigma_theta_copia;
dir2=dir_copia;
% Positions
Options2 = {'anglenorth',0,'angleeast',90,'labels',{'N','S','E','W'},'nFreq',5,'FreqLabelAngle',45,'nSpeeds',6,'Min_Radius',0,'TitleString',{'Temp.Instability - Wind rose';''},'LabLegend','Temperatur Instability','LegendVariable','{\sigma\theta}'};
% Windrose plot
[figure_handle,countn, speedsn, directionsn]= WindRose(dir2,spd,Options2);
But, again I got Erros:
Error using xlim (line 31)
Limits must be a 2-element vector of increasing numeric values.
Error in WindRose (line 349)
xlim(axs,[-radiusmax radiusmax]/scalefactor); % Set limits
Unfortunately I cannot show the data that I using.

采纳的回答

dpb
dpb 2018-4-27
Contact the author of the submission; perhaps will have some help/advice since was the author.
As for the last error,
Error in WindRose (line 349)
xlim(axs,[-radiusmax radiusmax]/scalefactor);
Don't have any idea what the function would have tried to do when given data all of negative value but looks like probably what is happening is that a radiusmax value is being computed from the data and wasn't thought about having only data<0 as an argument so that value is derived from the input and in this case is negative. A negative of a negative will be positive and the original negative will end up with the two values passed to xlim as being [+ -] and that definitely will crash xlim.
I'd guess your best bet will be to set a breakpoint in the function early on and follow the logic that determines the scale factor and fix it up so that it ends up using abs(radiusmax) for radiusmax as the first try. You might just get lucky and that be all that's needed.
  1 个评论
Teresa Rotava
Teresa Rotava 2018-4-27
Thank you so much. I tried already to contact the author, but he never answered. Anyway, any advice is welcome, so thank you!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matched Filter and Ambiguity Function 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by