How do I plot the different values in a for loop on the same plot? (confusing problem!)
显示 更早的评论
I am wanting to take axial cuts sweeping from right to left along the x co-ords -0.05 to -1.0 in -0.05 increments to get the force distribution between the upper and lower boundaries. As the shape I am taking the cuts through is roughly rectangular and sloping downwards from right to left (so a +ve gradient) the y co-ordinates are different (decrease) as you move to the left of the shape, so i normalized the coordinates so that they show as values between 0-100% of the shape boundary. This way all plots (at x=-0.05 to -1.0) should lie on top of each other but with different forces.
The problem I am having is that it is storing Ycut2, Ycut2_gap, Fcut2 as 1x23 matrices, where as I need them to be stored as that, but for every value of x i took the cut at (rather than just the last one or what ever it is storing).
I've attached what i have on it so far below:
--------------------------------------
X = 279x23 matrix (x co-ords [range from -2 to +2])
Y = 279x23 matrix (y co-ords [range from -2 to +2])
F = 279x23 matrix (force at x-y position [all +ve values])
--------------------------------------
for i = 1 : 23
for j = -0.05:-0.05:-1.0
Ycut2(i) = interp1(X(:,i),Y(:,i),j,'spline');
Fcut2(i) = interp1(X(:,i),F(:,i),j,'spline');
end
end
--
% normalizes co-ords so that it is between 0 - 100%
Ycut2_gap = max(Ycut2)-min(Ycut2);
for i = 1:23
Ycut2_range(i) = (Ycut2(:,i)-min(Ycut2)) / Ycut2_gap * 100;
end
--
figure
plot(Ycut2_range,Fcut2),axis image
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Interpolation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!