Plotting 2d data

조회 수: 5 (최근 30일)
darkphotonix
darkphotonix 2019년 4월 21일
댓글: Walter Roberson 2019년 4월 21일
Haven't touched Matlab in over two years, trying to create a graph plotting my answers. I'm getting an error "Index exceeds the number of array elements (1)."
%loop for thickness
for i = 3 : 1 : 10
%loop for number of fins
for j = 8 : 1 : 12
m(i) = sqrt((2*ho)/(k*t(i)/1000)); % m^-1
At(i,j) = fins(j)*Af+((2*pi*r2)-(fins(j)*t(i)/1000)); %m
n_o(i,j) = 1-(((fins(j)*Af)/At(i,j))*(1-(tanh(m(i)*(r3-r2))/(m(i)*(r3-r2)))));
R_to(i,j) = 1/(n_o(i,j)*ho*At(i,j)); % m*K/W
R_t(i,j) = R_conv + R_cond +R_to(i,j); % m*K/W
q(i,j) = (delta_T)/(R_t(i,j)); % W/m
plot(j,q(i,j),'b-',linewidth',2);
hold on
end
end
plot(fins,q,'r.','markersize',20,'linewidth',2);
set(gca,'fontsize',16,'fontweight','bold')
title('Heat Rate increase as fins and thickness increases');
xlabel('Number of Fins','fontsize',16);
ylabel('Heat Rate (W)','fontsize',16);

채택된 답변

Walter Roberson
Walter Roberson 2019년 4월 21일
t = 0.003 is a scalar, but you index t(i)
Caution: your i and j are scalars, so plot(j, q(i,j), 'b-') is going to try to plot a single point. plot() only ever draws a line you pass it two adjacent finite values in a single call. Your plot() call is not going to plot anything. If you were to alter the 'b-' to 'b*-' then it would at least place markers at the single points that it draws.
  댓글 수: 3
darkphotonix
darkphotonix 2019년 4월 21일
Gotcha, I completey spaced on that. How would I then seperate the plot points for each thickness on a graph
Walter Roberson
Walter Roberson 2019년 4월 21일
Parts of the code have mysteriously vanished and due to an allergy flare I don't seem to have successfully memorized it before it changed.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by