Search Comments and Ratings

go

   
Date File Comment by Comment Rating
16 Sep 2014 Unique Rows for a cell array Find unique rows of a cell array containing columns with strings or scalars, or N-D matrices Author: Jim Hokanson Alize

14 Sep 2014 urlread2 Generalizes HTTP requests, providing more control and access to input and output Author: Jim Hokanson Maxwell Agnew

I'm trying to use urlread2 to make a post request to the Etrade API. Their documentation says:

"Since this is a POST request, the parameters are included in the request as XML or JSON"

Can urlread2 handle a 'POST' request with the xml? An example would be much appreciated.
Thanks!

26 Aug 2014 Unique Rows for a cell array Find unique rows of a cell array containing columns with strings or scalars, or N-D matrices Author: Jim Hokanson Richard Mertens

Good job, worked fast on a 6000x3 ca of strings.

26 Aug 2014 Unique Rows for a cell array Find unique rows of a cell array containing columns with strings or scalars, or N-D matrices Author: Jim Hokanson Richard Mertens

22 Jul 2014 urlread2 Generalizes HTTP requests, providing more control and access to input and output Author: Jim Hokanson Francisco

Thanks

22 Jul 2014 urlread2 Generalizes HTTP requests, providing more control and access to input and output Author: Jim Hokanson Jim Hokanson

@Francisco,

My apologies on PATCH not working. This is a problem with the underlying Java classes. I'll try to look into alternative Java classes.

Jim

22 Jul 2014 urlread2 Generalizes HTTP requests, providing more control and access to input and output Author: Jim Hokanson Francisco

Hello.

http DELETE method works OK:

url ='https://api-fxpractice.oanda.com/v1/accounts';
header = http_createHeader('Authorization','Bearer XXXXXXXX-YYYYYYYYY');
urlread2(url,'DELETE','',header)

returns:

ans =

{
"id" : 619104742,
"instrument" : "EUR_GBP",
"units" : 1,
"side" : "buy",
"price" : 0.79643,
"time" : "2014-07-22T03:25:49.000000Z",
"type" : "BuyEntry"
}

Cheers

21 Jul 2014 urlread2 Generalizes HTTP requests, providing more control and access to input and output Author: Jim Hokanson Francisco

Thanks for your answer.

I get this error message when I use the PATCH method here:
header = http_createHeader('Authorization','XXXXXXXX-YYYYYYYYY');
params = {'units' '2'};
uparams = http_paramsToString(params);
url ='https://api-fxpractice.oanda.com/v1/accounts/1125870/orders/619104742';
urlread2(url,'PATCH',uparams,header)
Error using urlread2 (line 157)
Java exception occurred:
java.net.ProtocolException: Invalid HTTP method: PATCH

at java.net.HttpURLConnection.setRequestMethod(Unknown Source)

at sun.net.www.protocol.https.HttpsURLConnectionImpl.setRequestMethod(Unknown Source)

What do you think is causing it?
Cheers

Francisco

21 Jul 2014 urlread2 Generalizes HTTP requests, providing more control and access to input and output Author: Jim Hokanson Jim Hokanson

@Francisco,

Yes, both are. I've exposed the entirety of the HTTP request and response so you can do anything you want with it.

Jim

20 Jul 2014 urlread2 Generalizes HTTP requests, providing more control and access to input and output Author: Jim Hokanson Francisco

Hello. Thanks for your Help. Are http PATCH and DELETE methods supported? Thanks

20 Jul 2014 urlread2 Generalizes HTTP requests, providing more control and access to input and output Author: Jim Hokanson Jim Hokanson

@Francisco,

My apologies on the confusing documentation. When providing headers you also need to provide the body so that the order of the inputs is maintained. In this case providing an empty body is fine.

urlread2 (url,'GET','',header)

One day I'd like to rewrite this code base so that this is unnecessary and clearer ...

Best of luck and let me know if you have any other questions.

Jim

19 Jul 2014 urlread2 Generalizes HTTP requests, providing more control and access to input and output Author: Jim Hokanson Francisco

Hello,

I'm a newbie in MATLAB, I want to use MATLAB send http GET, POST, PATCH and DELETE commands to a REST API:

https://api-fxpractice.oanda.com/v1/accounts

for identification a header has to be sent in this format:
Parameter:Authorization
Value:Bearer XXXXXXXX-YYYYYYYYY

So I type:
header = http_createHeader('Authorization','Bearer XXXXXXXX-YYYYYYYYY')

url = 'https://api-fxpractice.oanda.com/v1/accounts'

urlread2 (url,'GET',header)

and I get this message:
Error using urlread2 (line 180)
Function input: body, should be of class char, uint8, or int8, detected: struct

Is this a problem with the header?

Thanks

Francisco

13 Jul 2014 urlread2 Generalizes HTTP requests, providing more control and access to input and output Author: Jim Hokanson Jim Hokanson

@Dan,

Usually problems arise due to the site using javascript. To get around this I'll usually use a program called "Fiddler" (In Windows). I'll go to the site in my web browser and then look at Fiddler to see what requests are being made to the server. Look for a request and subsequent response from the site that contains the information that you want. Then look more closely at the request to see how you would make the same request.

Best of luck.

Jim

13 Jul 2014 urlread2 Generalizes HTTP requests, providing more control and access to input and output Author: Jim Hokanson Dan

Thought that URLREAD2 would alleviate the issues I have using URLREAD to retrieve the contents of a URL page.
y = urlread( 'http://www.realtor.com/international/listing-detail/Costa-Guimar%C3%A3es_DISTRITO-DE-BRAGA_PO_666733');

Would like to extract information from the page (e.g. price). While I can see all the info in the source page (in the browser), there is no info in the return value from URLREAD2. Is the server somehow trying to protect the info? Anything that could be done?

Thanks a lot.

08 Jul 2014 Unique Rows for a cell array Find unique rows of a cell array containing columns with strings or scalars, or N-D matrices Author: Jim Hokanson Mike Shen

Awesome

25 Jun 2014 urlread2 Generalizes HTTP requests, providing more control and access to input and output Author: Jim Hokanson none poncho

Perfect solution for one of matlab's problems, but i'm experiencing difficulties in using it. I'm trying to upload binary contents. Can you please provide an example?

23 Jun 2014 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Stefan

Hi Jim,
I also have the 'Unexpected lead in header' error but when I try the fix you mention:
'This problem can be fixed by replacing the error you are seeing with:
flags = [];
info = [];
eof_error = true;
return;'

I get an error:
WARNING: File was not closed properly.
Data will most likely be missing at the end of the file
In an assignment A(:) = B, the number of elements in A and B must be the same.

Error in TDMS_readFileHelper_v1 (line 148)
data{I_object}(startI:endI) =
fread(fid,numValuesAvailable,precisionType{dataType});

Error in TDMS_readTDMSFile (line 252)
data = TDMS_readFileHelper_v1(fid,optionStruct,metaStruct,paramsStruct);

Error in TDMS_getStruct (line 57)
[temp,metaStruct] = TDMS_readTDMSFile(filePath,readOptions{:});

Any idea?
Stefan

03 Jun 2014 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Jim Hokanson

@Benoît

I have no idea what would be causing the problem you are referencing. Can you send me an example file that has this problem? I'll send a private message with more details.

Jim

03 Jun 2014 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Benoit

Hi Jim,

Thanks for your job.
I tried to use your code, and I don't have any error, but the file I get is empty. My original file is 70Mo, and the final one is only 10Mo.
Do you have any clue to help me ?
Thanks a lot.

Benoît

05 Mar 2014 urlread2 Generalizes HTTP requests, providing more control and access to input and output Author: Jim Hokanson Cary Belas

Perfectly solved my quesionts

14 Feb 2014 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Jim Hokanson

@David

I've really wanted to change that interface for a while :/

The issue is that the input should be a structure ARRAY that contains strings.

getStruct.group = '6120';
getStruct.channel = 'Untitled 3';

Feel free to email if you need more help.

Jim

13 Feb 2014 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson David DeVilbiss

Jim,

back on 22-Feb-2014, Joe Cuschieri had a question concerning reading in segments of data using your functions. I'm getting the same errors. Did you have a solution for him or some sample code to simple read in segments of data.

Thanks, Dave

04 Feb 2014 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Jonathan Currie

Great bit of code, worked first time, just how it should be!

21 Jan 2014 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Jim Hokanson

@Joe,

National instruments won't release the specs for their daqmx format (I've asked), so I don't know what their binary data means. They recently updated their dll to support reading version 2 files, so you might have luck using that. I've been meaning to look at the dll but it's really low on my priority list at this point.

The link to the dll can be found at this page:
http://digital.ni.com/public.nsf/allkb/A3663DE39D6A2C5A86257204005C11CA

There used to be a specific page for the dll (in which it said it supported only version 1, and then recently version 2) but I can't find it anymore.

Good luck and feel free to email me if you have any more questions.

Jim

21 Jan 2014 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Joe

Hello,

I get a strange error when trying to use TDMS_readTDMSFile:

It tells me:
"Error using TDMS_processLeadIn (line 50)
Currently code is unable to ignore/handle Raw Daq MX data

Error in TDMS_preprocessFile (line 179)
[flags,info,eof_error] = TDMS_processLeadIn(fid,lastLetter);

Error in TDMS_readTDMSFile (line 226)
metaStruct = TDMS_preprocessFile(fid,tdmsFileName,paramsStruct);"

Surely the program is fit to handle raw DAQmx data right? How can I avoid this error?

28 Nov 2013 urlread2 Generalizes HTTP requests, providing more control and access to input and output Author: Jim Hokanson Clemens

This function solved my long waiting time of the java call findproxyforurl. Thank you!

22 Oct 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Jim Hokanson

@Bob,

Sorry about the obtuse error message. In the new version I've been working on I am hoping to provide links to lengthy documentation on what each error message actually means. Each section of the tdms file starts with the characters tdsm (data file) or tdsh (if it is the index file). If those are not present, it indicates that there was either an error in parsing the file, or in writing the file. I think every time I've seen this error, the issue has been that the file is not closed properly (using tdms close in Labview) and the last segment is corrupted.

This problem can be fixed by replacing the error you are seeing with:
flags = [];
info = [];
eof_error = true;
return;

If you have any more problems feel free to contact me via email.

Jim

21 Oct 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Bob

I'm trying to help a coworker decode a message he is getting reading tdms files I'm creating. We read a lot of files and we occasionally see an error with the following format:

Error getting TDMS struct: 2013-10-17 16_50_15_902.tdms
MException with properties:

identifier: ''
message: 'Unexpected lead in header'
cause: {0x1 cell}
stack: [6x1 struct]

Is there anything that explains what this error means so I can correct it?

Thanks!

17 Oct 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Jim Hokanson

@Kadir,

Please get in touch with me via email and perhaps send a complaint to NI.

Jim

17 Oct 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Kadir

@ Jim,

Thanks a lot for the clarification. I don't have Excel. I tried the dll but it takes only first 1000 values of the sample. Therefore, I'd like to go for the 3rd option.

What do you mean by "regular array" and how can I perform this conversion?

Thanks again, Kadir

16 Oct 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Jim Hokanson

@Kadir,

That flag is updated on every segment, and is not constant throughout the file. The format of that type of data is not specified by NI even after I requested it. Alternatives include:
- trying the Excel TDMS reader
- trying their new dll code which might support Raw DaqMX code
- converting the data in Labview from Raw DaqMx into a regular array, and then using my code

Feel free to email me if you have any more questions.

Jim

16 Oct 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Kadir

Hi,

I got the error "Currently code is unable to ignore/handle Raw Daq MX data". Then, I looked at TDMS_processLeadIn, line 49-51:

if flags.hasRawDaqMX
error('Currently code is unable to ignore/handle Raw Daq MX data')
end

Then, I checked the value of "hasRawDaqMX" field of the struct "flags". It was 0. Then, I shouldn't get the error which is implemented in the line 50, right?

Does anybody have any idea what's going on?

Thanks in advance, Kadir

11 Oct 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Harry

@Jim

Works perfect for me! Great!

Thank u very very much!!!!!

10 Oct 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Jim Hokanson

@Harry,

You need to add the tdmsSubfunctions folder to your path as well. I had originally placed those in a separate folder to try and make it more obvious which functions you would call and which ones you wouldn't. Sorry about the confusion.

Jim

10 Oct 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Harry

Hey Jim,

I got a problem with your code.
If I want to convert a .tdms file, I always receive errors.

for example:
>> filename = 'C:\Users\*****\Desktop\v2p5\tdms\Messdaten.tdms';
>> my_tdms_struct = TDMS_getStruct(filename);
Undefined function 'TDMS_handleGetDataOption' for input arguments of type 'struct'.

Error in TDMS_readTDMSFile (line 216)
TDMS_handleGetDataOption('check',paramsStruct)

Error in TDMS_getStruct (line 57)
[temp,metaStruct] = TDMS_readTDMSFile(filePath,readOptions{:});

Can u explain, whats the problem?

07 Oct 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Jim Hokanson

Hi all,

I recently came across a bug in my code which I expect impacts very few people and for the majority of people it impacts, the following error will most likely be thrown "The remaining data doesn't split evently into chunks." That being said, it is a bug and I'll try and get a fix out soon. From what I can tell it would cause a problem if you occasionally decide not to write a subset of a group of channels, and at other times you write the entire group. Something like:

If case1
channels = 1:3
else
channels = [1 3]
end

In my opinion this error actually goes against the NI documentation so I need to contact them to for clarification.

More details to follow.

Many thanks to Junghwan Kim for sending a sample file to me which allowed me to finally understand this problem.

Jim

07 Oct 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Henrik

Hi!

I am getting the following error while running step 2,3 and 4 in your example file "TDMS_exampleFunctionCalls".
Can you please help me?

Error using fseek
Invalid file identifier. Use fopen to generate a valid file identifier.

Error in TDMS_preprocessFile (line 155)
fseek(fid,0,1);

Error in TDMS_readTDMSFile (line 226)
metaStruct = TDMS_preprocessFile(fid,tdmsFileName,paramsStruct);

Best Regards
Henrik

16 Sep 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Jim Hokanson

@Navid,

Given that NI won't release the data format specs for RawDaqMX data, your options are the following:
1) Tell NI you want the specs released
2) see 1)
3) Try this:
http://www.ni.com/white-paper/4906/en

Good luck

16 Sep 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Navid

Dear Jim,
Thanks for your fast answer,
you were right about wrong code but after using your code I got same errors as Jury and Jane,unfortunately I am not able to resave the data,is there other ways to get around this problem?!

many thanks..

15 Sep 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Jim Hokanson

@Navid,

It seems like you might be using different code:
http://www.mathworks.com/matlabcentral/fileexchange/28771-converttdms-v9

I would recommend you using my code instead. Let me know if you still have problems.

Jim

15 Sep 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Navid

Dear Jim,
at first thank you so much for your code,I have problem with some kinds of TDMS files,could you help me plz?! I get this:
Converting 'ADC_20130808_165723.tdms'...Undefined function or variable 'TDMSFileNameShort'.

Error in convertTDMS>getSegInfo (line 405)
e=errordlg(sprintf(['Seqment %.0f within ''%s'' has interleaved data which is not
supported with this '...

Error in convertTDMS (line 276)
[SegInfo,NumOfSeg]=getSegInfo(fid);

27 Aug 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Junghwan

Hi Jim,

Firstly, I deeply appreciate for your code.

I get the same error as Robert and Fiona.
It looks like you answered Fiona via email. Could you share your answer to Fiona?

Many thanks!

Error using TDMS_preprocessFile (line 450)
The remaining data doesn't split evently into chunks, estimated #
of chunks: 5.000000e-01

Error in TDMS_readTDMSFile (line 226)
metaStruct =
TDMS_preprocessFile(fid,tdmsFileName,paramsStruct);

Error in TDMS_getStruct (line 57)
[temp,metaStruct] = TDMS_readTDMSFile(filePath,readOptions{:});

06 Aug 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson CLF

04 Aug 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Jim Hokanson

@Jane

The short answer is that there is no solution. The format of Raw Daq MX data is proprietary and NI has refused my request for documentation.

The easiest way to get around this if you are still looking to use my code is to read the data file using Labview and to resave the data not using Raw Daq MX.

04 Aug 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Jane

Hello!

I have been having the same error as Jury. Could you possibly post a solution?

Cheers!

13 Jul 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Jim Hokanson

@Jury

Please send me an email regarding this problem.

12 Jul 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Jury

Hi!

I try to read TDMS file, created LV2012 (12.0.1f2) in Matlab R2013a, 64bit, and obtain error:

Error using TDMS_processLeadIn (line 50)
Currently code is unable to ignore/handle Raw Daq MX data

Error in TDMS_preprocessFile (line 179)
[flags,info,eof_error] = TDMS_processLeadIn(fid,lastLetter);

Error in TDMS_readTDMSFile (line 226)
metaStruct = TDMS_preprocessFile(fid,tdmsFileName,paramsStruct);

Error in TDMS_getStruct (line 57)
[temp,metaStruct] = TDMS_readTDMSFile(filePath,readOptions{:});

Is any suggestion for reading TDMS file?

Jury

21 Jun 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Jim Hokanson

@Cole ??? - What fix? Please contact me via email to discuss specifics.

Thanks,
Jim

21 Jun 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Cole Van Vlack

I should also mention I did try the fix you gave before. When I use it, I get the following error,

---------
Error in TDMS_processLeadIn (line 27)
Ttag = fread(fid,1,'uint8');

Output argument "eof_error" (and maybe others) not assigned during call to "E:\Data\Cobra Integration
Test\v2p5\tdmsSubfunctions\TDMS_processLeadIn.m>TDMS_processLeadIn".

Error in TDMS_preprocessFile (line 179)
[flags,info,eof_error] = TDMS_processLeadIn(fid,lastLetter);

Error in TDMS_readTDMSFile (line 226)
metaStruct = TDMS_preprocessFile(fid,tdmsFileName,paramsStruct);

Error in TDMS_getStruct (line 57)
[temp,metaStruct] = TDMS_readTDMSFile(filePath,readOptions{:});

Error in test (line 4)
my_tdms_struct = TDMS_getStruct(filename);

08 Jun 2013 TDMS Reader Read TDMS files v1 & v2 without DLL Current Version: 2.5 Author: Jim Hokanson Zeb

Worked fine on Matlab 2010, now trying to use with Matlab 2008.

Getting this error:
"??? Error: File: TDMS_readTDMSFile.m Line: 134
Column: 3
Expression or statement is incorrect--possibly
unbalanced (, {, or [."

How do I solve this?

Contact us