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 ビュー (過去 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!