Contour Plotting matrix size issue

조회 수: 17 (최근 30일)
Kelly
Kelly 2013년 2월 15일
I am trying to plot computations using the contour plot, but am not sure how to because my z variable is the computation results and the dimensions are larger than y and x.
b = [0.1, 1.0, 10, 100];
R = (1:0.2:5);
theta = 45;
[F] = ratio_rp_bf(b,R,theta); 5x21
x = R.*cos(theta); 1x21
y = R.*sin(theta);1x21
z = [F];
Am I trying to plot the wrong things?
  댓글 수: 3
Image Analyst
Image Analyst 2013년 2월 15일
I don't know. Where is your call to the contour() function or the plot() function?
Kelly
Kelly 2013년 2월 15일
편집: Kelly 2013년 2월 15일
this is my function
function [F] = ratio_rp_bf(b,R,theta)
for i = 1:length(b)
for r = 1:length®
F(i,r) = (16/3).*(1./b(i)).*(1./R(r)).^3.*sqrt((1./R(r)).^4-2.*(1./R(r)).^2.*cos(2.*theta)+1);
end
end
this is as far as I've gotten in terms of plotting a 2x2 subplot, everytime I do another subplot it looks exactly the same. I'm trying to get it to plot for each b value.
b = [0.1, 1.0, 10, 100]; R = (1:1.2:5); theta = atan(R/b); [F] = ratio_rp_bf(b,R,theta);
x = R.*cos(theta);
y = R.*sin(theta);
z = F;
figure(1)
subplot(2,2,1)
contour(x,y,z)
grid on
xlabel('b/D50')
ylabel('radii')
title('Radial Pressure vs. Bed Forces')

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2013년 2월 15일
When you use
contour(XVALUES, YVALUES, ZVALUES)
then XVALUES should be a vector of length size(ZVALUES,1), and YVALUES should be a vector of length size(YVALUES,2). Your Z is 5 x 21, and your R is of length 21 (so your y is too), but you do not appear to have any variable of length 5 to supply for XVALUES.
Are you sure you want to contour? And not that you want to plot 5 lines in 3 space?
  댓글 수: 1
Kelly
Kelly 2013년 2월 15일
this is my function
function [F] = ratio_rp_bf(b,R,theta)
for i = 1:length(b)
for r = 1:length®
F(i,r) = (16/3).*(1./b(i)).*(1./R(r)).^3.*sqrt((1./R(r)).^4-2.*(1./R(r)).^2.*cos(2.*theta)+1);
end
end
this is as far as I've gotten in terms of plotting a 2x2 subplot, everytime I do another subplot it looks exactly the same. I'm trying to get it to plot for each b value using contour.
b = [0.1, 1.0, 10, 100]; R = (1:1.2:5); theta = atan(R/b); [F] = ratio_rp_bf(b,R,theta);
x = R.*cos(theta);
y = R.*sin(theta);
z = F;
figure(1)
subplot(2,2,1)
contour(x,y,z)
grid on
xlabel('b/D50')
ylabel('radii')
title('Radial Pressure vs. Bed Forces')

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by