Problem with getting results for plotting (X,Y)
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Armin Majidian
el 27 de Mzo. de 2021
Comentada: DGM
el 27 de Mzo. de 2021
- Question is:
- X axis (t) = from 0 to 30;
- Y axis (A) = if command; if t>=10 and if not,
Error:
Subscript indices must either be real positive integers or logicals.
Error in SpecifyLineStyleColorAndMarkerExample (line 9)
A(t) = rav * t;
A=ones(1,30);
rav = 0.5;
rln = 0.1;
for t = linspace (0,30,31);
if t<=10
A(t) = rav * t;
else
A(t)= rav*10 + rln * (t-10);
end
end
0 comentarios
Respuesta aceptada
DGM
el 27 de Mzo. de 2021
The index t increments through the integers 0 to 30. While it's true that t is always an integer, it is not a positive integer. For the first pass through the loop, t=0. A has no zeroth element. Matlab uses a 1-based indexing convention, so perhaps:
for t=1:30
would work (provided all the other math works out).
4 comentarios
DGM
el 27 de Mzo. de 2021
Oh, my bad. In this context, since t is not an index, you can use:
t=0:30;
Más respuestas (0)
Ver también
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!