read_grib, where to put ibm2fltmex5.dll - matlab

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

Related

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.

save_system on non writable file MATLAB command

I try to save mdl in old fomart
save_system(fullfile(fullpath, myModel(k).name), fullfile(fullpath, myModel(k).name),'SaveAsVersion', 'R2011b');
I'm getting an error saying that the file I'm trying to save is not writable
how could I make it writable ?
I don't find a similar arg as for copyfile(...'f')
any idea ?
Thanks,
There is a function to modify file attributes:
fname=fullfile(fullpath, myModel(k).name);
fileattrib(fname,'+w');
You could also use java:
fname=fullfile(fullpath, myModel(k).name);
java.io.File(fname).setWritable(true)

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.

error using save can't write file

I have got this really strange error in matlab. When I try to run the command
save(fullfile('filepath','filename'),'var','-v7');
I get the error message,
error using save can't write file
but when I try
save(fullfile('filepath','filename'),'var','-v7.3');
everything works fine. The the variable takes some space on the workspace, 165MB, but the I would guess that the size should not be an issue here. Does anyone know why it does not work to save in v7?
For the one that want to confirm the size of the variable, I will add the whos information,
Name Size Bytes Class Attributes
myName 1x1 173081921 struct
BR/ Patrik
EDIT
The variable I try to save is a struct with plenty of fields. I have tried to save a 3 dimensional matrix of size 800 mb, which went through without problems.
This is not an exact match to your problem, but I received the same error message when trying to save to -v6 format. Matlab is supposed to issue an error when a variable type or size is not supported:
help save
...
If any data items require features that the specified version does not support, MATLAB does not save those items and issues a warning. You cannot specify a version later than your version of MATLAB software.
Matlab's error checking seems to not be perfect, because there are certain situations (dependent on Matlab version and the particular variable type) that just fail all together with this not so helpful error message:
Error using save
Can't write file filename.mat.
For example, saving a string with certain unicode characters with the '-v6' option in Matlab r2015b in Linux produces the error, but Matlab r2016a in Windows does not. This is the output from my Matlab r2015b session:
>> A=char(double(65533))
A =
?
>> save('filename.mat','-v6','A')
Error using save
Can't write file filename.mat.
Without having your specific variable to test with, but seeing that the error messages match, I suggest removing parts of your data structure until it will save in order to isolate the variable that is causing it to fail.

how to connect or load file.dll to 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