The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Automation Server/COM and LabVIEW
 Adding data to graph (MATLAB)

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
sudd0030 Posted - 01/26/2016 : 6:56:11 PM
Hi,

In the MATLAB example, the following lines were used to add data to the graph:

% Add data to data range
invoke(dr, 'Add', 'X', worksheet, 0 , 0 , -1, 0 );
invoke(dr, 'Add', 'Y', worksheet, 0 , 1 , -1, 1 );

What do these last four digits signify?
My only guess right now is that the last digit is the column from which the data is taken, but when I add more lines for an extra data series like this:

invoke(dr, 'Add', 'X', worksheet, 0 , 0 , -1, 0 );
invoke(dr, 'Add', 'Y', worksheet, 0 , 1 , -1, 1 );
invoke(dr, 'Add', 'X', worksheet, 0 , 0 , -1, 2 );
invoke(dr, 'Add', 'Y', worksheet, 0 , 1 , -1, 3 );

The resulting graph looks very screwy (see image here: http://imgur.com/7IIV13Q) with straight lines across that shouldn't be there and the data looping back on itself oddly.


Thanks,
John

Origin 2016
Operating System: Win10
4   L A T E S T    R E P L I E S    (Newest First)
zrehman809 Posted - 10/30/2018 : 04:35:42 AM

There is more than one way to read data into MATLAB from a file. The simplest, though least flexible, the procedure is to use the load command to read the entire contents of the file in a single step. The load command requires that the data in the file be organized into a rectangular array. No column titles are permitted. One useful form of the load command is
load name.ext
where ``name.ext'' is the name of the file containing the data. The result of this operation is that the data in ``name.ext'' is stored in the MATLAB matrix variable called name. The ``ext'' string is any three character extension, typically ``dat''.
sudd0030 Posted - 01/29/2016 : 11:15:26 AM
Thank you!
I'm starting to realize that the relevant documentation for the automation servers is spread across all of the other Origin documentation.
Castiel Posted - 01/29/2016 : 04:59:08 AM
quote:
Originally posted by sudd0030

So the screwy lines seem to be coming from Origin improperly interpreting NaN cells from MATLAB (instead of NaN, the cells contain: -1.#IND).

As a fix for this, I simply converted my data from a double array to a cell array using num2cell(data). Origin is able to successfully interpret NaN in a cell array for some reason.

I'm still confused about the four digits in this command:
invoke(dr, 'Add', 'X', worksheet, 0 , 0 , -1, 0 );

and would greatly appreciate documentation on what each digit does.



int Add(LPCSTR Type, Worksheet wks, int r1, int c1, int r2, int c2 )


1. r1 - index of first row of the range, starting from 0
2. c1 - index of first column of the range, starting from 0
3. r2 - index of the last row of the range, starting from 0 and -1 means the last available row
4. c2 - index of the last column of the range, starting from 0 and -1 means the last available column

It's not explained in AutomationServer.chm, but OriginC.chm. Or you may check this: http://www.originlab.com/doc/OriginC/ref/DataRange-Add

©c¡Ï   ¤È¥¹  ©f¨u©c  ©c¥ì    ¥Î¤³  ©c/     ©¦£¯
 ©c¨Ê¥Î ¤´¥¨  ¥ó ¨×   ¥ó¤á' ¥Ì©¦¥­   /¤í  ¥Õ©¦©f
   ¨Ö             ¦á          ©¦£þ  ©` ¥Õ   ©¦
                              ©¦
sudd0030 Posted - 01/27/2016 : 12:22:19 PM
So the screwy lines seem to be coming from Origin improperly interpreting NaN cells from MATLAB (instead of NaN, the cells contain: -1.#IND).

As a fix for this, I simply converted my data from a double array to a cell array using num2cell(data). Origin is able to successfully interpret NaN in a cell array for some reason.

I'm still confused about the four digits in this command:
invoke(dr, 'Add', 'X', worksheet, 0 , 0 , -1, 0 );

and would greatly appreciate documentation on what each digit does.

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000