convert data into matrix

i have a data in notepad file (data is many numbers in many rows and columns) ,, how i can read it as a matrix 2x2 only using matlab code ?

6 Comments

you need to explain this more. a 2x2 matrix has only 4 elements, yet you say your data has many numbers. If it has more than 4 what do you want? multiple 2x2 matrices? stacked with a 3rd dimension? Give an example of the data file and an example of what the output should be.
this is the data file (notepad file)
and the output should be as this matrix
Don't attach images, attach text so somebody can a) read it, and b) do something with it besides look
What you're asking still doesn't make any sense...what are the four elements in the second image and how do they relate to a file as you've shown?
The content of the file is comma-separated-variables ("CSV") file; you can read it simply into MATLAB with any number of tools, skipping the one header line.
What you do with the data then is up to you...
the content of the data file related to a result taken from a network analyzer, the result was a figure for S parameter then it exported to data file. now i need to read the file as a 2x2 matrix.
You cannot do that. The information you need for the 2 x 2 output that you expect, is not contained in the input file.
dpb
dpb on 2 Mar 2020
Edited: dpb on 3 Mar 2020
In fact, what is in the data file is the frequency trace from the analyzer for the eight signals; what was derived from that isn't in the file.
There may be some other way the instrument can download what you're looking for, but this wasn't it.
ADDENDUM:
Or maybe there was another file created and you've just opened the wrong one???

Sign in to comment.

Answers (1)

Try
data = csvread(filename, 1, 1) % old MATLAB
or
data = readmatrix(filename, 'numHeaderLInes', 1); % new MATLAB

5 Comments

No. If you examine the desired output, you see the entries are on the order of 500, about 5E+002 . When you examine the low-resolution image of the data file, we see data in the range of 2E+9, and various values E-001, E-002, E-003, and E-004. There are no entries that we can see on the order of E+002 . The required data cannot be obtained with csvread or readmatrix -- at least not without heavy processing for with some formula that is not even close to being obvious.
I didn't actualy try it. Can Raneem attach the file so people can try it? And I didn't understand the desired output. There is many, many columns and many, many rows, so where is each 2-by-2 matrix, in the 3-D stack of such matrices, supposed to come from in the original source matrix? I have no idea. And why does the headerline use semicolon delimiters while the data uses comma delimiters?
dpb
dpb on 3 Mar 2020
Edited: dpb on 4 Mar 2020
Raneen has a network analyzer that computes S-Parameters for his DUT. But, what he's output to the file are the raw measurments for the input/output channels vs frequency, not the computed S-parameters that he's wanting. Undoubtedly the instrument has the facility to do so, but we don't know the particular one he has, so that's nothing we can do.
In theory, he can compute from the data therein, but that's the hard way to go at once the instrument has already done so. A pretty nice whitepaper on S-Parameters/measurement by a particular instrument vendor.
Sigh, looks like what I thought was a 5 is really an S. The desired output was being shown in a pattern, whereas I was reading the desired output as being actual values such as 521
Ah! I had an advantage in knowing what he was talking about when he made the first followup to confirm what I first suspected. He's looking for what will be a complex array for each of the four elements represented symbolically in the image...but that's not the data in the file he has there; those appear to be the individual trace amplitudes by frequency w/o the phase information (PSDs roughly).

Sign in to comment.

Tags

Asked:

on 2 Mar 2020

Commented:

dpb
on 4 Mar 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!