Can anybody tell me why my windrose program doesn't plot the right graph and the cardinal directions change back to degress after selecting a date?

39 vues (au cours des 30 derniers jours)
I got it to plot the graph but just clicking one date changes the graph all the time and the graph isn't even right.

Réponse acceptée

Madheswaran
Madheswaran le 16 Nov 2024 à 16:34
The issue occurs because the polar axes settings are not being maintained after plotting new data. When plotting new data with 'polarhistogram', MATLAB creates a new plot that resets all polar axes properties. To fix this, you should reconfigure the polar axes after plotting the dataAfter calling 'polarhistogram', reapply the custom axis configuration.
Here is the modified 'plotData' function, that reapplies the custom axis configureation:
function plotData(selectedDates)
str = get(dateList, 'String');
lc = numel(str);
am = get(dateList, 'Value');
selectedDate = get(dateList, 'String');
selectedIdx = get(dateList, 'Value');
if numel(selectedDates) <= 4
set(header, 'String', selectedDate(selectedIdx));
elseif numel(selectedDates) < lc
an = numel(am);
set(header, 'String', ['Histrogram - ', num2str(an), ' Päeva']);
elseif numel(selectedDates) == lc
selectedMonth = sheets{get(monthPopup, 'Value')};
set(header, 'String', selectedMonth);
end
% Plot histogram with specified bin count
angles = rand(1, 100) * 2 * pi; % Placeholder for actual data
polarhistogram(hPolarAxes, angles, 'BinEdges', linspace(0, 2*pi, 24)); % 23-24 bins
% Reapply the polar axes configuration based on the current radio button selection
selectedRadioButton = radioGroup.SelectedObject;
numDirections = str2double(selectedRadioButton.Tag);
configurePolarAxes(hPolarAxes, numDirections);
end
Replace the 'plotData' from 'testitesti.m' file with the above code. These changes maintain the cardinal direction labels (E, NE, N, etc.) instead of reverting to degrees when new data is plotted.
Regarding the incorrect graph plotting, you'll need to verify your actual wind direction data and binning logic, as the current code uses random placeholder data for 'angles' (angles = rand(1, 100) * 2 * pi).
Hope this helps!

Plus de réponses (0)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by