Plotting 2d data
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
darkphotonix
am 21 Apr. 2019
Kommentiert: Walter Roberson
am 21 Apr. 2019
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);
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 21 Apr. 2019
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 Kommentare
Walter Roberson
am 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Title finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!