Plotting 2d data

6 次查看(过去 30 天)
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