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

John Petersen
John Petersen 2020년 3월 2일
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.
Raneem Alshair
Raneem Alshair 2020년 3월 2일
this is the data file (notepad file)
and the output should be as this matrix
dpb
dpb 2020년 3월 2일
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...
Raneem Alshair
Raneem Alshair 2020년 3월 2일
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.
Walter Roberson
Walter Roberson 2020년 3월 2일
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 2020년 3월 2일
편집: dpb 2020년 3월 3일
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???

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2020년 3월 3일

0 개 추천

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

댓글 수: 5

Walter Roberson
Walter Roberson 2020년 3월 3일
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.
Image Analyst
Image Analyst 2020년 3월 3일
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 2020년 3월 3일
편집: dpb 2020년 3월 4일
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.
Walter Roberson
Walter Roberson 2020년 3월 4일
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
dpb
dpb 2020년 3월 4일
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).

댓글을 달려면 로그인하십시오.

태그

질문:

2020년 3월 2일

댓글:

dpb
2020년 3월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by