hi,
i've got three vectors: a,b,c. each of it with length=97.
i need to do a 3d matrix, in which i'll have a,b,c..
i'm sure that is very simple, but i've found some
difficulties:/
In article <g0jmli$ah$1@fred.mathworks.com>,
mark b. <john.doe.nospam@mathworks.com> wrote:
>i've got three vectors: a,b,c. each of it with length=97.
>i need to do a 3d matrix, in which i'll have a,b,c..
>i'm sure that is very simple, but i've found some
>difficulties:/
Please explain more clearly what the 3D matrix output should
look like. Based upon what you said, it looks to me to be
more likely that you want the 2D matrix
output = [a(:);b(:);c(:)]
If not then my next best guess would be that you want
--
"We worked every day, Sunday included, until at least ten
o'clock at night. I remember it was an event when we quit work
on Christmas night at eight o'clock to attend a family reunion."
-- Walter Davidson (of Harley-Davidson)
"mark b." <john.doe.nospam@mathworks.com> wrote in message
<g0m449$nsj$1@fred.mathworks.com>...
> sorry, i took a look once again and it's not exacly what i
> wanted.
> consider:
>
> a=1:5;
> b=2:6;
> c=3:7;
> [ta tb tc] = ndgrid(a,b,c);
> output = cat(3,ta,tb,tc);
>
> then size(output) will be 5x5x15
> and i need the matrix to be 5x5x5 (axbxc)
What matrix? What do you want this matrix
to hold? You have never yet told us this
information, just the size of it.
zeros(97,97,97)
will give you an array of the originally
requested size.
i know i can make make matrix = zeros(97,97,97) and then
i'll have 3d matrix size 97x97x97.
but then i want to put inside of it a,b,c, where each is
the size of 97. so then i'll still have matrix with size
97x97x97 but with a,b and c inside..
"mark b." <john.doe.nospam@mathworks.com> wrote in message
<g0m8d6$so0$1@fred.mathworks.com>...
> i know i can make make matrix = zeros(97,97,97) and then
> i'll have 3d matrix size 97x97x97.
> but then i want to put inside of it a,b,c, where each is
> the size of 97. so then i'll still have matrix with size
> 97x97x97 but with a,b and c inside..
(John takes a quiet moment to pound his
head against a brick wall. While this does
not directly relieve the pain he feels in his
head, it distracts him. It seems better now.)
But you still have not said what is in this
matrix.
A simple array in Matlab is composed of
scalar elements, each of which is a SINGLE
number or character. Those elements may
be the standard double precision numbers,
or they may be singles, uint8s, etc.
So it makes no sense that you want to put
a, b, and c inside this array. There are other
classes of variables in Matlab, such as cell
arrays or structures. And there are higher
dimensional arrays. Do you perhaps wish to
create a 4 dimensional array?
So again, what will be inside each element
of this array? Please explain yourself, as my
crystal ball is always foggy at this time of
day.
> i know i can make make matrix = zeros(97,97,97) and then
> i'll have 3d matrix size 97x97x97.
> but then i want to put inside of it a,b,c, where each is
> the size of 97. so then i'll still have matrix with size
> 97x97x97 but with a,b and c inside..
Let's reduce this to 2D, and vectors and matrix with size 4. So I have
two 4-element vectors: [1 2 3 4] and [5 6 7 8]. I want a 4x4 matrix.
Write out the 4x4 matrix which describes where the above numbers go:
On May 17, 5:27=A0am, "mark b." <john.doe.nos...@mathworks.com> wrote:
> i know i can make make matrix =3D zeros(97,97,97) and then
> i'll have 3d matrix size 97x97x97.
> but then i want to put inside of it a,b,c, where each is
> the size of 97. so then i'll still have matrix with size
> 97x97x97 but with a,b and c inside..
------------------------------------------
mark b./john doe
So go ahead and do it. Just stick the 3 vectors in. You'll have 3
lines of numbers in a mostly empty array. Go ahead and stick them
anywhere you want - what do I care? (Others may have their own
suggestions of where you can stick them.) Sounds like you consider
this as a solution since you've stopped asking questions.
- skeptic
Tags for this Thread
Add a New Tag:
Separated by commas
Ex.: root locus, bode
What are tags?
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.