Array indices must be positive integers or logical values
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
VBBV
on 3 Dec 2020
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;
See Also
Categories
Find more on Digital Filter Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!