If I have m1 = 12, m2 = 34, m3 = 12, m4 = 45 how have the right to I conserve it in the kind of y = using a because that loop? type of like.. For i = 2:6 y = ?.... Thanks


The most crucial question is: exactly how did you end up with all of those separate variables? The ideal solution is come avoid producing lots of variables. How? by using simply one variable... And luckily it is trivial to avoid as soon as loading/importing data or when creating data, by making use of indexing or fieldnames. So, given that the is so trivial to stop this problem, when not boost your code by avoiding this whole trouble altogether?
The name MATLAB originates from MATrix LABoratory: MATLAB is most effective when data is maintained together as lot as feasible (in vectors, in matrices, or in ND arrays) and also the data accessed using indexing or by writing vectorized code. Like plenty of other programming languages it is really inefficient to generate or accessibility lots of different variables.

You are watching: How to store values in an array matlab

About the worst systems would be to use eval (which part beginners love to use), you could like to very first know what the MATLAB documentation says about it: "A regular use the the eval role is to create sets that variables such together A1, A2, ..., An, however this strategy does not use the selection processing power of MATLAB and is no recommended."
You might also like to review what experienced MATLAB users say around what you space trying to execute (hint: they strongly advise against it):


I calculated the typical pixel"s worth for several different images utilizing MATlab, that"s exactly how I ended up with different variables. I want to put them together now to graph those values vs. Time.


"I calculate the mean pixel"s value for several different images utilizing MATlab, that"s exactly how I ended up with different variables"
So the best and simplest equipment is to put that data into one variable as soon as you make those calculations. The is what any type of experienced user would do, and also you have the right to do the too.
Presumably you do those calculations in a loop: in that instance you can simply preallocate the calculation matrix and use indexing within the loop come allocate the calculate values. Simple, fast, efficient, neat, easy to understand... Over there is no reason why you cannot write an excellent code now.


As argued above: The finest idea is not to produce the variables in this means at all. Hiding an table of contents in the surname of the variable is a negative idea.
But if you have actually these names already and cannot change the code, which creates them - what"s dorn with:
? Is the variety of variables unknown? execute the variables come indigenous an imported MAT file? then this would certainly help:

Community endowment Hunt

Find the treasures in MATLAB central and uncover how the ar can assist you!

start Hunting!

An Error Occurred

Unable to finish the activity because of changes made come the page. Reload the page to see its to update state.

pick a internet Site

Choose a web site to gain translated content where accessible and see local events and offers. Based on your location, we recommend the you select: .

select internet site

How to Get ideal Site Performance

Select the China website (in Chinese or English) for ideal site performance. Other tacoemojishirt.com country sites space not optimized for visits from your location.

See more: What Time Was It 8 Hours Ago ? 8 Hours Ago From Now & Time After 8 Hours


Accelerating the speed of engineering and science

tacoemojishirt.com is the top developer the mathematical computer software because that engineers and scientists.