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?
38 views (last 30 days)
Show older comments
Markus
on 16 Nov 2024 at 14:01
Commented: Markus
on 18 Nov 2024 at 14:47
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.
0 Comments
Accepted Answer
Madheswaran
on 16 Nov 2024 at 16:34
Hi @Markus
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!
More Answers (0)
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!