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);

 Risposta accettata

Walter Roberson
Walter Roberson il 21 Apr 2019

1 voto

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 Commenti

madhan ravi
madhan ravi il 21 Apr 2019
Even fins is a scalar.
darkphotonix
darkphotonix il 21 Apr 2019
Gotcha, I completey spaced on that. How would I then seperate the plot points for each thickness on a graph
Walter Roberson
Walter Roberson il 21 Apr 2019
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.

Accedi per commentare.

Più risposte (0)

Categorie

Community Treasure Hunt

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

Start Hunting!

Translated by