I get an error when trying to plot

1 次查看(过去 30 天)
I do not get a line when I graph this. I am very new to coding and am struggling with the graphs.
clear
q=38.89 ; %W/m^3
r_o=0.04 ;
T_oo=5 ;
k=0.5 ;
c=10.1 ;
V=.1:1.0 ;
Temp(V)=q/(6*k)*(r_o^2)+(q*r_o)/(3*(c*V^0.425))+T_oo ;
Array indices must be positive integers or logical values.
Temp(Temp==0)=[];
figure
plot(.1:1,Temp)
xlabel('V *10^-1(m/s)')
xlim('auto')
ylim('auto')
ylabel('Temp (C)')
title('Temperature of center vs air velocity')

采纳的回答

Image Analyst
Image Analyst 2023-5-15
Try making V a vector, and then using ./ and .^ because it's a vector:
clear
q=38.89 ; %W/m^3
r_o=0.04 ;
T_oo=5 ;
k=0.5 ;
c=10.1 ;
V = linspace(.1, 1.0, 500);
Temp = q/(6*k)*(r_o^2)+(q*r_o) ./ (3*(c*V.^0.425)) + T_oo
Temp = 1×500
5.1573 5.1563 5.1553 5.1543 5.1534 5.1524 5.1515 5.1506 5.1497 5.1489 5.1480 5.1472 5.1464 5.1456 5.1449 5.1441 5.1434 5.1427 5.1420 5.1413 5.1406 5.1399 5.1393 5.1386 5.1380 5.1374 5.1367 5.1361 5.1356 5.1350
Temp(Temp==0)=[];
figure
plot(V, Temp, 'b-')
grid on;
xlabel('V *10^-1(m/s)')
xlim('auto')
ylim('auto')
ylabel('Temp (C)')
title('Temperature of center vs air velocity')

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Printing and Saving 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by