how to create contour with looping for each every data

1 view (last 30 days)
Dear all, I have several data ZA000060, ZA000120, ZA000180, ZA000240, and ZA000300. now I would to create contour for each data with looping. truthfully, I feel difficult to do that. any help would be great. Thanks alot
  1 Comment
Stephen23
Stephen23 on 14 Apr 2016
Edited: Stephen23 on 27 Jun 2019
" truthfully, I feel difficult to do that."
Yes, it is difficult.
The reason it is difficult is because you chose to store your data in separate variables. If you had put all of your data in just one variable then it is trivial top loop over it using indices (or fieldnames). This has already been explained to you in your earlier question:
and you even accepted an answer that put those data into one cell array. So you took a simple answer using a cell array and by removing the cell array made your own life much more complicated (because now you cannot access those variables very easily).
It really is that simple: using one variable solves your problem.
Bad program design makes difficult, slow, and buggy code. And by storing all of your data in separate variables you just made accessing those data more complicated that if you put them simply into one variable. No matter how many times beginners love to dream up the idea that they can access lots of variables dynamically, it is actually just slow, buggy, and obfuscated code.
Best solution: store your data in one variable, then use indexing or fieldnames to access it. This will be much much faster, neater, and more reliable than any hack solution you can find to access lots of variables.

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements 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!