Here's the link of the program.
Here's the link of the original waveform.
Here's the link of the imported waveform.
Here's the ratio.
The strange thing is that the imported waveform looks same as the original waveform,I have expected to get a scalar ratio when use the original data ./ the imported data, but surprisingly the ratio points are so scattered.
Is there anyone can tell me why? Or recommend to me a program to import TDMS file.
Related
I saw online that you can just use edit rgb2gray to open up the source file, but I ran into another function in the rgb2gray.m file that I don't know how to view.
Lines 54-55 contain the following function:
if threeD
I = images.internal.rgb2graymex(X);
How do I view the source code for this rgb2graymex function?
rgb2graymex is, as its name suggests, a .mex file. .mex files are pre-compiled files which you thus cannot view the contents of, unless you use exotic decompilers (which usually don't give a 100% result), or obtain the source code from the one who's written it, which is not going to happen with proprietary code.
Read more on MEX files on the MathWorks site.
In general you can't see the contents of a .mex file, as #Adriaan indicates in his answer.
You mention in the comments, though, that what you really want is to find the coefficients used from the transform matrix for converting RGB to grayscale. You can find these in the code immediately below the section you quote:
T = inv([1.0 0.956 0.621; 1.0 -0.272 -0.647; 1.0 -1.106 1.703]);
coef = T(1,:);
That gives me:
coef =
0.298936021293775 0.587043074451121 0.114020904255103
Now it's true that you can't demonstrate conclusively that the .mex file is doing the same thing as this; but the .mex file is just there to speed things up when you pass in a big mxnx3 RGB image, rather than a small nx3 RGB colormap. I'd be very surprised if it was using different coefficients. A few experiments that I've just done indicate only the tiniest of numerical differences (<1e-15) between the .mex file and using the coefficients present in the code.
I designed a filter and applied it to a random noise signal using SPTool in MATLAB. My noise signal was x = (1/sqrt(2))*(randn(1024,1)+j*randn(1024,1))
Once I've applied my filter to this noise signal, how can I take that filtered signal and use it as a file source in GNU Radio Companion (which I will connect to QT GUI Frequency Sink)? I tried exporting the signal using SPTool but I'm unsure what file extension I can use for GNU Radio. Thanks in advance.
Use fwrite with the right precision parameter that gives you float 32 binaries.
Or just use the octave/Matlab scripts in GNU Radio that do exactly that: write raw binary data. For more info, see the GNU Radio FAQ entry on the file format. (On https://wiki.gnuradio.org )
If you have a .mat file, another option is to use a Vector Source block putting in the Vector field:
loadmat('filename')['varname'].flatten()
For this to work you need to:
import numpy
from scipy.io import loadmat
Note this loads the whole file in memory (but you can specify which variables to load from the file if that's a problem). Also if the data is stored as float64 (as is the norm in Matlab) then I think there could be some rounding/truncation since GR Vector Source expects float32 (don't know enough about how SWIG handles that).
i am trying to import a .tif image into matlab with the following code
>> aa = imread('house.tif');
i get the error
Error using rtifc
TIFF library error: '_TIFFVSetField: C:\Users\user\Documents\MATLAB\house.tif: Null count
for "Tag 34022" (type 1, writecount -3, passcount 1).'.
Error in readtif (line 49)
[X, map, details] = rtifc(args);
Error in imread (line 434)
[X, map] = feval(fmt_s.read, filename, extraArgs{:});
as i am using matlab for the first time in my life i really have no idea what this error means. Please help is required in this matter.
MATLAB R2012b has a bug and it cannot read TIFF files properly. More information can be found here: http://www.mathworks.com/matlabcentral/newsreader/view_thread/326232
Probably Matlab does not support the specific type of tif. In Matlab's defence, tif is not an easy file-format to read. It supports plenty of compression schemes, multiple pages and who knows what. I'd convert the tif to png and go with that.
Update: A quick Google search revealed that "rtifc" is a Matlab mex-wrapper around libtiff. Your error appears to come from libtiff. If the latter can't read it, your tif will probably be problematic for a lot of other applications too.
Another thing you could try is use the implementation tiffread from François Nedelec's group at EMBL. http://www.embl.de/ExternalInfo/nedelec/misc/matlab/tiffread29.m. It's heavily used by biology folks all over the world. I've been using it for many years.
Ok, so this question is related to my ongoing task of getting text data categorized, you can refer to this question for more details on how I approached this problem.
I used the standard matlab function "nctool" (neural clustering tool) to get my inputs organized on a plane of 10x10 SOM nodes. I also got the output of this map (i.e. which of my inputs ended up on which node) saved in to the "output" variable in my workspace.
I would now like to get this data out and see if I can write another script. I'm aware of the 'save' and some of the export functions in MATLAB, however it seems that MATLAB does not support ascii export of this variable since it is a sparse matrix.
I am currently writing a script to get this thing exported out, however if someone already has a solution, please post. Otherwise I will do so after I finish testing it.
Update: I found a workaround to this fairly easily:
% convert a sparse matrix to full
output = full(output);
% output this to a file (excel)
xlswrite('test.csv',output);
I want to import a .raw file into MATLAB as a matrix (frames x spatial x spectral). Is there a built-in function to do this?
If you're referring to a raw image file from a camera, I would check out the submission RAW Camera File Reader from Bryan White on the MathWorks File Exchange.
You can also read the file directly. But you'll need to convert it to DNG first. See this:
http://blogs.mathworks.com/steve/2011/03/08/tips-for-reading-a-camera-raw-file-into-matlab/