Borrar filtros
Borrar filtros

How do I subplot from a large file? Note..any .txt file of any large figures can be given. So please solve generally.

1 visualización (últimos 30 días)
I have to plot time against distance. But any .txt file will be given which may contain any number of datas. How do I subplot them in a loop?
  6 comentarios
Rik
Rik el 11 de Mayo de 2021
It is good that you showed the code you tried, however, without a better description (even with MS Paint) of the intended result, it is hard to help you. Also, you should post your code as code, instead of a screenshot.

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 11 de Mayo de 2021
You could calculate N more cleanly as
N = size(r, 1);
T and c and r will each be a single column.
You take the number of rows in r, and take the square root of it, and want to do subplots; if everything works out and the number of input rows was a square integer, you would end up with a number of subplots equal to the number of rows.
In each iteration, you go to plot one column . But r and c only have one column, so the second iteration would produce an error.
You should not be calculating
cols = ceil(n./rows)
Suppose for example there were 50 rows to start, so N = 50, so rows = floor(sqrt(50)) so rows = 7. Then n = [50 1] (because size(r(:,end)) is going to be a vector of length 2, the second element of which is 1). [50 1]./7 is [7.14<etc>, 0.14<etc>]. ceil([7.14<etc>, 0.14<etc>]) is [8 1]. But using [8 1] as a subplot bound is an error. You should be using cols = ceil(N./rows)
Now you go to iterate i = 1 : N and you go to plot() one column each time. But there is only one column... You could switch to using i as the row index, but if you did that you would be plotting only one point per subplot.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by