convert data into matrix
Afficher commentaires plus anciens
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 commentaires
John Petersen
le 2 Mar 2020
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
le 2 Mar 2020
dpb
le 2 Mar 2020
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
le 2 Mar 2020
Walter Roberson
le 2 Mar 2020
You cannot do that. The information you need for the 2 x 2 output that you expect, is not contained in the input file.
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???
Réponses (1)
Image Analyst
le 3 Mar 2020
Try
data = csvread(filename, 1, 1) % old MATLAB
or
data = readmatrix(filename, 'numHeaderLInes', 1); % new MATLAB
5 commentaires
Walter Roberson
le 3 Mar 2020
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
le 3 Mar 2020
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?
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
le 4 Mar 2020
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
le 4 Mar 2020
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).
Catégories
En savoir plus sur LaTeX dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

