Defining table reference using list contents
Mostrar comentarios más antiguos
Please note that the following code examples are not meant to be correct but to illustrate the issue.
The following 2 lines ARE in my working MatLab code...
figure('Name','xy098')
scatter(xy098.x,xy098.y, '.');
plot(dt098.x1, dt098.y1,"O");
However, I have a lot of individual tables I would like to plot.
I envisage a list...
list1 = {'094','114','124','134','096','106','116','126','126','098','108','118','128','138'};
That I could then use to reference each table through looping through the list...
for i=0 to (length of list - 1) {
figure('Name','xy' + list1(i))
scatter(xy + list1(i).x,xy + list1(i).y, '.');
plot(dt + list1(i).x1, dt + list1(i).y1,"O", "markerFaceColor", "r", "markerEdgeColor", "r", "markerSize", 8);
}
My intention would then to output each graph produced as a .png for analysis (that's a later problem).
I cannot identify how to do such an assignment to variable name.
2 comentarios
"However, I have a lot of individual tables I would like to plot."
You did not tell us the most important information: how did all of these tables get into the workspace? The point at which they were created/imported is the correct place to fix this badly-designed data. For example, by load-ing into an output structure:
S = load(...);
and then trivially looping over its fields:
Your current inadvisable approach is one way that beginners force themselves into writing slow, complex, inefficient, obfuscated, buggy code that is hard to debug. Read this to know why:
For reference, an earlier question which hints at the start of this bad data design:
Gary Newport
el 25 de Ag. de 2020
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!