问题
I am having difficulty making all of my subplots in a (3,4,i) plots have exactly the same axes, all starting at zero. The code I have so far is below but it returns all subplots with varying x and y scales.
Can anybody help?
%% plot
for i = 1:num_bins;
h = zeros(ceil(num_bins),1);
h(i)=subplot(4,3,i);
plotmatrix(current_rpm,current_torque)
end
linkaxes(h,'xy');
axis([0 30 0 8]);
回答1:
You should move the memory allocation outside of the loop:
%% plot
h = zeros(ceil(num_bins),1);
for i = 1:num_bins;
h(i)=subplot(4,3,i);
plotmatrix(current_rpm,current_torque)
end
linkaxes(h,'xy');
axis([0 30 0 8]);
来源:https://stackoverflow.com/questions/15554899/linkaxes-for-all-subplots-in-a-for-loop