Plot outputs for eqn for varying inputs
1 次查看(过去 30 天)
显示 更早的评论
I would like to plot the outputs of an equation, when varying one of the inputs.
NP = 5: 1: 15
A lot of code to calculate other variables, some including the NP conditions, relating to my final equation of...
GRR_SF = ...
I would then like to plot NP against GRR_SF, thus for the conditions of NP = 5, 6, 7 ...15.
I have my results for GRR_SF in the form below, computed by MATLAB:
Columns 1 through 9
10.8105 12.5702 14.1122 15.5015 16.7762 17.9607 19.0717 20.1214 21.1191
Columns 10 through 15
22.0717 22.9849 23.8631 24.7101 25.5291 26.3226
However, when plotting
xlabel('Number of Parts')
ylabel('CI')
title('CI with varying # Operators')
plot(NP, GRR_SF)
the graph comes up without any data points, incorrect x & y spacings, no titles on axis or graph.
0 个评论
回答(1 个)
Jaswanth
2024-2-9
Hi Luke,
From the information you have given, it appears that the primary issue causing the problems you have mentioned is the mismatch in the number of elements between the 'GRR_SF' array and the 'NP' array. If the element counts are unequal, MATLAB will not display the data accurately, which might lead to the incorrect spacing of the x and y axes.
According to the MathWorks documentation for the 'plot' function, "To display a series of points connected by lines, you should ensure that X and Y are vectors of the same length."
To visualize the graph with both data points and connecting lines, you can specify a 'marker' along with a 'line style'in the 'plot' function. Kindly go through the example code below.
% The 'o-' option will create a plot with both data points and connecting lines
plot(NP, GRR_SF, 'o-');
Additionally, I am able to see the axis labels and the title correctly when plotting in MATLAB R2022a.
Kindly refer to following link of MathWorks documentation on ‘plot’ function for more information: https://www.mathworks.com/help/matlab/ref/plot.html?searchHighlight=plot&s_tid=srchtitle_support_results_1_plot
I hope that the details provided will aid in troubleshooting the issues.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!