How to call consecutive variables from workspace

3 views (last 30 days)
Hi!
As all of you where once, I am really new to MatLab. I have a script which uses many timesteps and displays the result before the new timestep is starting. Furthermore it is saving the results as variables in a subfolder.
I am running the script on a linux machine via remote and cannot use the GUI-mode, since without, the computation takes about ~30mins and in GUI-mode it takes - depends on where I am - from 6 to more than 19 hrs (!!!!). My favorite solution would be to increase the time-lag in the remote connection, but I already read some threads about it and it just seems to be an annoying MatLab-Problem. If any of you has an easy solution, please post.
So MY solution is to save the figures in command line mode as .jpg files. My problem is now, that the variables start with H1 and are going up to H900. I know, that the command figure is not possible in no-GUI mode, but figure ('Visible', 'off') should be. This now is just for designing a test case in GUI mode
for j=1:timestep
fig=figure()
mesh (double(H(j)(:,3:end)))
saveas(h, ['H' num2str(j) '.png']
end
at "mesh(double(H(j)(:,3:end)))" I try to grab every variable from H1 to H900, but it won't work. I also tried "mesh(double ['H' num2str(j)] (:,3:end)))", but nothing works for me. I know the answer is simple, but I can't find it.
Cheers Gabe

Answers (2)

Daniel Shub
Daniel Shub on 31 May 2013
I am a little lost about what your question is, but I think you are saying that working with variables called H1, H2, H3, ..., H900 is difficult. There is a "solution" which uses the command eval and doesn't require you to change anything else. I am not going to give you that "solution", because it isn't the correct way. The correct way is to NOT name your variables H1, H2, ..., H900. If the variables are all the same size, then simply add an extra dimension onto H.
mesh(H(:, 3:end, j))
ideally this extra dimension will be the last dimension so everything will stay the same size.

Gabriel
Gabriel on 3 Jun 2013
Sorry, that I confused you. But after you said, that giving variables consecutive numbers is not the right way, I started to built in the mesh command in the file producing the variables, which are actually temporary files, beeing pressed into one result.
Anyway thanks for your help!

Categories

Find more on Startup and Shutdown 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!