COMPGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Creating matrix

• Email
• Follow

```Hello there. I've got a question:
I have text a file made by N^2 lines. i need to create from it a NxN matrix. is there a function to do it? i hope so!

than you!

Akis
```
 0
Reply akismitracos (1) 10/14/2010 6:33:05 AM

See related articles to this posting

```Akis <akismitracos@gmail.com> wrote in message <1995775092.104231.1287052415202.JavaMail.root@gallium.mathforum.org>...
> Hello there. I've got a question:
> I have text a file made by N^2 lines. i need to create from it a NxN matrix. is there a function to do it? i hope so!
>
> than you!
>
> Akis

Yes there are many functions.
Start by importing the file with textscan and then ask a more specific question with a brief example of your input and the desired output.

Oleg
```
 0

```Dear

> I have text a file made by N^2 lines. i need to create from it a NxN matrix.

You can use TEXTREAD, TEXTSCAN or FSCANF to get a N^2 vector. Afterwards RESHAPE and perhaps TRANSPOSE let to bring this vector into a NxN shape.

Good luck, Jan
```
 0

2 Replies
206 Views

Similar Articles

12/6/2013 3:28:45 AM
page loaded in 27017 ms. (0)

Similar Artilces:

Matrix in a matrix?
Hi to all, I've encountered a problem using Matlab. As I'm not very familiar with matlab, there are functions which I have not used before. What I would like to know, if there is a way to express a matrix within a matrix. For example, R= [ r1 r2 r3 ... rn] where rn=[xn yn tn] and xn, yn, tn are column of numbers. I used the following code below to express the numbers in rn as coloumns for easy referencing. xn=r(:,1); %represents the columns in the matrix yn=r(:,2); tn=r(:,3); My objective is to be able to retrieve information in the matrix easily and compare their values. Meaning, the user will specify n and the numbers in the columns. thanks for the help.. Regards, Cy use a strucure of arrays .. look it up in matlab help Cheers, Venkat On May 21, 12:28 am, CY <ychangy...@hotmail.com> wrote: > Hi to all, > > I've encountered a problem using Matlab. As I'm not very familiar > with matlab, there are functions which I have not used before. > > What I would like to know, if there is a way to express a matrix > within a matrix. For example, > > R= [ r1 r2 r3 ... rn] > > where rn=[xn yn tn] > > and xn, yn, tn

input matrix
Hi, i'm learning how to use lapack library (in particular, Intel MKL). I wish to know how I have to format the my inputs. I'm calling lapack functions from c++ (zhetri. zhemm, zgemm, zhseqr, ztrevc). I declare the 3x3 matrix (in c++) in this way: complex MyMatrix[9]; I intend MyMatrix[0], MyMatrix[1], MyMatrix[2] as the first row, but i'm not sure that also lapack routine interpret this the same way (and not MyMatrix[0],MyMatrix[3],MyMatrix[6] as the first row). So, how I have to manage matrixes, column major or row major (like in c++)?. Thank you aberte@gmail.com <aberte@gmail.com> wrote: > i'm learning how to use lapack library (in particular, Intel MKL). I > wish to know how I have to format the my inputs. I'm calling lapack > functions from c++ (zhetri. zhemm, zgemm, zhseqr, ztrevc). > I declare the 3x3 matrix (in c++) in this way: > complex MyMatrix[9]; > I intend MyMatrix[0], MyMatrix[1], MyMatrix[2] as the first row, but > i'm not sure that also lapack routine interpret this the same way (and > not MyMatrix[0],MyMatrix[3],MyMatrix[6] as the first row). > So, how I have to manage matrixes, column major or row

The inverse of a Matrix
Hellow! I got a question about Maxtrix inverse; I have a eqation group as following: A*x=c; where, A is a known 14 by 14 matrix, x is a 14 by 1 known vector, c is also a 14 by 1 vector. I substituted the known value x into the equation above, then i got the result c, but when i do the inverse to get the x as following using the calculated value of c: Inv(A)*c, I found the value of x is different with the known value of x, the inverse of matrix A exist. Any one has a suggestion about it? thank you! Mike Mike wrote: > Hellow! > I got a question about Maxtrix inverse; > I have a eqation group as following: > A*x=c; > where, A is a known 14 by 14 matrix, x is a 14 by 1 known vector, c > is also a 14 by 1 vector. I substituted the known value x into the > equation above, then i got the result c, but when i do the inverse to > get the x as following using the calculated value of c: > > Inv(A)*c, > > I found the value of x is different with the known value of x, the > inverse of matrix A exist. > > Any one has a suggestion about it? thank you! 1) How big is the difference? 2) What is the result of svd(A)? Post these and we can help

Integrating a Matrix
I have a 3X3 matrix of functions fij[x], for i,j = 1,2,3, and I want to NIntegrate all nine elements over 0<x<1 to get a matrix of constants. Is there an easy way to do this other that doing 9 individual NIntegration's?

symmetric matrix
Sorry for the elementary question, but is there a function I can call in MATLAB that would return 1 if a matrix is symmetric and zero if not? Chris "Chris " <solidsnake56982000@yahoo.com> wrote in message <h03jdm\$aek\$1@fred.mathworks.com>... > Sorry for the elementary question, but is there a function I can call in MATLAB that would return 1 if a matrix is symmetric and zero if not? > > Chris one of the many solutions % the data m=[ 1 2 3 2 9 4 3 4 1 ]; % a macro issym=@(x) all(all(tril(x)==triu(x).')); tf=issym(m) % tf = 1 m(1,3)=-10; tf=issym(m) % tf = 0 us On Jun 2, 12:37=A0pm, "us " <u...@neurol.unizh.ch> wrote: > "Chris " <solidsnake56982...@yahoo.com> wrote in message <h03jdm\$ae...@fr= ed.mathworks.com>... > > Sorry for the elementary question, but is there a function I can call i= n MATLAB that would return 1 if a matrix is symmetric and zero if not? > > > Chris > > one of the many solutions > > % the data > =A0 =A0 =A0m=3D[ > =A0 =A0 =A0 =A0 =A0 1 2 3 > =A0 =A0 =A0 =A0 =A0 2 9 4 > =A0 =A0

Matrix coordinate,
Hi, I have matrix and i want to find the coordinate of the first 1 that appeared in the matrix, that is row and column number, here is my code so far, D = 0 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 >> [m,n] = size (D) m = 4 n = 7 >> G = find (D, m, 'first') G = 8 13 18 21 >> G = min(find(D,m,'first')) G = 8 I need to gewt the row and column number of this 8, which should be m = 4 and n= 2, but i don't know how to, i know its preety basic, but please help me! >> [x y]=find(D==1,1,'first') x = 4 y = 2 Here you go! "Jeff K" <mesta2000@hotmail.com> wrote in message <i1m8ic\$501\$1@fred.mathworks.com>... > >> [x y]=find(D==1,1,'first') > x = > 4 > y = > 2 > > Here you go! Thank you soooooo much!!! you are a life saver!!!!!

Matrix computations
Hello, I have a matrix which contains the numbers from 0 to 7, where 0-7 are randomly chosen in each element of the matrix. I have made a section of code that calculates the percentage of times numbers 0-7 appear which is outputted in the from of a 1x8 array. the matrix i'm calculating the percentages from is M x N x 3. This piece of code i made does that quite well: [x,y] = size(A); B = cat(3, A==0, A==1, A==2,A==3,A==4,A==5,A==6,A==7); for index = 1:1:8 z(index) = sum(sum(B(:,:,index)))/(x*y); end However i'm a bit stuck as to how I would calculate the percentage for each of the colours occurring in each row. not quit sure how to extract the info from the initial 'A' matrix. You could probably use nnz() instead of sum(sum()) to count the nonzero elements on each page. That said, to find the percentage of each number in each row, you could do something like, for i=1:8 C = A==(i-1); Z(:,i) = sum(C,2)/size(A,2); end Then each column of Z corresponds to one of the numbers 0-7, and each entry in the column is the decimal percentage of that number in that row. As a check, notice that sum(Z,2) produces all ones. Josh Meyer

enlarging matrix
Hi- I have a matrix A=[ 1 1; 1 1]; I want to insert zeros around each value like this: B=[ 0 0 0 0 0 0; 0 1 0 0 1 0; 0 0 0 0 0 0; 0 1 0 0 1 0; 0 0 0 0 0 0]; Do you have any good idea to do this? Thanks! "Young Ryu" <ryuyr77@gmail.com> wrote in message <h5fgaf\$bu7\$1@fred.mathworks.com>... > Hi- > > I have a matrix > A=[ 1 1; 1 1]; > > I want to insert zeros around each value like this: > B=[ 0 0 0 0 0 0; > 0 1 0 0 1 0; > 0 0 0 0 0 0; > 0 1 0 0 1 0; > 0 0 0 0 0 0]; > > Do you... 0 %} us "Young Ryu" <ryuyr77@gmail.com> wrote in message <h5fgaf\$bu7\$1@fred.mathworks.com>... > Hi- > > I have a matrix > A=[ 1 1; 1 1]; > > I want to insert zeros around each value like this: > B=[ 0 0 0 0 0 0; > 0 1 0 0 1 0; > 0 0 0 0 0 0; > 0 1 0 0 1 0; > 0 0 0 0 0 0]; > > Do you have any good idea to do this? > Thanks! Why did you "zero-pad" the inner column twice and the inner row only once? "Young Ryu" <ryuyr77@gmail.com> wrote in message <h5fgaf\$bu7

Matrix Inversion
Somebody can tell me how can I invert a matrix non-symetric and non-triangular using the ".i." operator? Thanks >Subject: Matrix Inversion >From: porteiro-rs@bol.com.br (porteiro) >Date: 1/9/04 10:08 AM Pacific Standard Time >Message-id: <1e208da0.0401091008.77497240@posting.google.com> > >Somebody can tell me how can I invert a matrix non-symetric and >non-triangular using the ".i." operator? >Thanks > There is no such operator in fortran ( though you can define your own operators ). As for matrix inversion... you have to code your own there also. Dan :-) porteiro-rs@bol.com.br (porteiro) wrote in message news:<1e208da0.0401091008.77497240@posting.google.com>... > Somebody can tell me how can I invert a matrix non-symetric and > non-triangular using the ".i." operator? > Thanks As Dan Tex1 points out, Fortran 95 does not have an intrinsic ".i." operator. The IMSL Fortran 90 MP LIBRARY that comes with Compaq Visual Fortran, Profession Edition, does define ".i." to invert a matrix. So you either write your own matrix inversion and overload it to ".i." (which I

matrix mulitplication...................
Hi, I am having one doubt can we do matrix multiplication by using sas. I think we have to follow arrays concept. suppose I am having the data sets like the following. data set name: first column names : A B A B 1 2 3 4 another data set name : second column names : C D C D 4 5 6 7 I want to get the output like the following data set name : Mulitiply_first_second column names : E F E F 16 19 36 43 In the final data set i need to get the matrix mulitplication......... If anybody help me to get the above code it will be very useful to me......