how to connect or load file.dll to matlab? - matlab

I want through matlab tutorial but I did not understand it clearly.
Could anyone can explain to me step by step how to load and call .dll functions in matlab?
I tried to use loadlibrary function but I get and error, if anyone can tell we where to put the .dll file and the .h file?

I don't do this often, but i usually do something like:
fullpathToHeader = 'c:\full\path\to\a\header.h';
fullpathToDll = 'c:\full\path\to\a\libraty.dll';
loadlibrary(fullpathToDll, fullpathToHeader);
Then if that works, you can call library functions as:
[outArg1, outArg2, ...] = calllib('library','function',inArg1, inArg2, ...)

See the following link, which contains some problems I encountered and overcame, when trying to load a dll into matlab:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/341602

Related

Unable to run code for DSP-SIFT in MATLAB

So, I got the code for DSP-SIFT from the original works of the author in the form of a toolbox. When I followed the instructions and tried to get it to run in MATLAB :
>> dsp_setup
>> dsp_mosaic
Undefined function 'vl_usift' for input arguments of type 'single'.
Error in vl_dspsift (line 50)
frames = vl_usift(im);
Error in dsp_mosaic (line 68)
[f1, d1] = vl_dspsift(im1g, opt);
After Googling this error(I am new to MATLAB), I found a solution saying that maybe my function cannot be recognised by MATLAB, so I need to add the containing folder to the MATLAB search path, which I tried doing:
>> which vl_usift -all
'vl_usift' not found.
>> addpath ('/home/dsp_toolbox_v0.0.2/dsp_toolbox_v0.0.2/toolbox/sift/')
Howver, I get the same error when trying to run the code.
I can add the code if it helps, but I do need advice on how to proceed from here.
Thanks
So, after a few hours of searching around, I finally came across the problem, there were a few lines commented in the setup file which I had to uncomment. Simple and frustrating.
Thanks!

What is the full command for gdal_calc in ipython?

I've been trying to use raster calculation in ipython for a tif file I have uploaded, but I'm unable to find the whole code for the function. I keep finding examples such as below, but am unsure how to use this.
gdal_calc.py -A input.tif --outfile=result.tif --calc="A*(A>0)" --NoDataValue=0
I then tried another process by assigning sections, however this still doesn't work (code below)
a = '/iPythonData/cstone/prec_7.tif'
outfile = '/iPythonData/cstone/prec_result.tif'
expr = 'A<125'
gdal_calc.py -A=a --outfile=outfile --calc='expr' --NoDataValue=0
It keeps coming up with can't assign to operator. Can someone please help with the whole code.
Looking at the source code for gdal_calc.py, the file is only about 300 lines. Here is a link to that file.
https://raw.githubusercontent.com/OSGeo/gdal/trunk/gdal/swig/python/scripts/gdal_calc.py
The punchline is that they just create an OptionParser object in main and pass it to the doit() method (Line 63). You could generate the same OptionParser instance based on the same arguments you pass to it via the command-line and call their doit method directly.
That said, a system call is perfectly valid per #thomas-k. This is only if you really want to stay in the Python environment.

How can I change the name of the file being saved without editing the code? MatLab

I am working on an experiment that take a lot of data samples and save it to different video files. For example, I take data and save it to a file called "slowmotion.avi" and then I take another set of data and save it to another file called "normalspeed.avi".
I am trying to find a way that I could change the name of file being saved without editing the code. The way I am using right now makes me have to open the code and change the name of the file directory within the code and then save the code. I want to make it a lot faster and easier to use.
I have tried the following code to fix this problem but it doesn't work.
graph=input('Graph of experiment: ');
vidObj = VideoWriter('%3.1f.avi\n',graph);
.....
Hope I didn't confuse you.
A possible solution:
graph=input('Graph of experiment: ','s');
vidObj = VideoWriter([graph,'.avi']);
The 's' in the input() function indicates that the expected input is a string, and [graph,'.avi'] simply concatenates both strings.

how i can resolve error of paddedsize in matlab?

Undefined function or method 'paddedsize' for input arguments of type 'double'
how i can resolve this.
f = imread('cameraman.tif');
PQ=paddedsize(size(f));
F=fft2(f,PQ(1),PQ(2));
sig=40;
H=lpfilter('ideal',PQ(1),PQ(2),sig);
imshow(fftshift(H),[ ]);
G=H.*F;
g=real(ifft2(G));
g=g(1:size(f,1),1:size(f,2));
figure;
imshow(g,[ ]);
paddedsize is not a MATLAB builtin or library function. Presumably this comes from some third-party library you should try and find.
'paddedsize' is a function available on the Matlab File Exchange Here. In order to use the function you will need to download the m-file into your working directory or add the file location to your path.

read_grib, where to put ibm2fltmex5.dll

I need to read some Meteological data in grib format. I have download a code which can read the data. but in the middel of code ibm2fltmex5.dll is needed. I have download the dll too from ibm2fltmex5.dll. I have created folders (MeteoLab\Read_GRIB) in (C:\Program Files\MATLAB\R2009a\toolbox) and put the dll in it.I restart my PC but that code error again.
function bds_struct=get_bds(fid,lenbds)
bds=fread(fid,11);
bds_struct.len=lenbds;
bds_struct.oct4=bds(4);
bds_struct.bsfE=int2(bds(5),bds(6));
bds_struct.RefVal=ibm2fltmex5(bds(7:10));
bds_struct.nbits=bds(11);
bds=fread(fid,lenbds-11);
bds_struct.bindata=uint8(bds);
error is
Undefined function or method 'ibm2fltmex5' for input arguments of type
'double'
.
Did I put dll in the correct place? what else should I do?
Any comments is appriciated.
I find another Way, there is a Matlab function which do the same: can be download from :
ibm2flt.m