i want to form a matrix using certain calculated values, how to do that? is there any particular command available ?? or a program? please help.

3 views (last 30 days)
i have certain calculated scalar values, using which i want to form a matrix, how do i do that?

Accepted Answer

Stephen23
Stephen23 on 12 Mar 2015
Edited: Stephen23 on 12 Mar 2015
Your question is far to general to give a specific answer: the name MATLAB comes from MATrix LABoratory, so of course there are many ways that you can define matrices. You don't say anything about how you "have certain calculated scalar values", so how are we supposed to know if these are already assigned to variables, or are in some cell array or structure, or are the outputs of calculations that you have performed in the command window?
If you are learning about MATLAB then you should work through all of these tutorials, which cover such basic concepts as how to create a matrix:
There is not enough time in our lives to teach every beginner the first baby-steps of MATLAB. You need to put in that effort yourself, and you will also learn more.
To answer your question: some basic methods are
  • concatenate values together values using square brackets: A = [1,2,3;4,5,6];
  • assign the output of a fucntion: A = fun(...);
  • read the values from a file: A = dlmread(...);
  • operate on and concatenate values using cellfun, accumarray, etc.
  2 Comments
jeenia bhadra
jeenia bhadra on 13 Mar 2015
well thanks _Stephen. I would like to explain my problem with a simple example. suppose I have a 3 by 4 matrix, and I form other matrices from it by increasing the elements by +2 each and form 10 other matrices as such. Then I proceed to do certain calculations as addition of the first rows, or the diagonals, for each of the matrix and get scalar quantities as results, say 4 results. Now I want to store the results in a matrix. How to do that? I have tried by initially storing them in an array form, and then looping them, but it wasn't useful.
Stephen23
Stephen23 on 13 Mar 2015
Edited: Stephen23 on 13 Mar 2015
We can help you, but you still need to give us a bit more to work with here... in your explanation it is not clear how these various matrices are related: you start with X with size 2x3, add two to get Y=X+2, but then how does this "form 10 other matrices as such"? I see only two so far: X and Y.
A much more detailed explanation would us understand what you are doing, and then we could help in return. You should upload your attempt so far (please as a file, not as text here), and write a more detailed explanation.

Sign in to comment.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices 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!