Array indices must be positive integers or logical values
1 次查看(过去 30 天)
显示 更早的评论
When I try to save the "t" and "v" values into the x(i) and y(i) vectors, I keep getting th same mistake. "Array indices must be positive integers or logical values."
Im trying to save tha value of each itiretation so I can plot all of them, anyone got another solution for this?
clc;
clear;
clc;
h=.12
rtanque=.1
rsalida=.005
g=9.806;
for i = (h:-.01:.00001)
Vol=(pi.*rtanque.^2).*i;
v=(2.*g.*i).^(1/2)
Q=(2.*(pi.*rsalida.^2)).*v;
t=Vol/Q
x(i)=t
y(i)=v
end
plot(x,y);
xlabel('Tiempo en [s]')
ylabel('Velocidad en [m/s]')
title('Gráfica Velocidad vs Tiempo')
grid on;
hold on;
0 个评论
回答(1 个)
VBBV
2020-12-3
clc;
clear;
clc;
h= linspace(0.00001,0.12,12)
rtanque=.1
rsalida=.005
g=9.806;
for i = 1:length(h)
Vol=(pi.*rtanque.^2).*i;
v=(2.*g.*i).^(1/2)
Q=(2.*(pi.*rsalida.^2)).*v;
t=Vol/Q
x(i)=t
y(i)=v
end
plot(x,y);
xlabel('Tiempo en [s]')
ylabel('Velocidad en [m/s]')
title('Gráfica Velocidad vs Tiempo')
grid on;
hold on;
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Digital Filter Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!