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 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Madheswaran
2024-11-16,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!
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!