cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

READEXCEL

SOLVED
BG_9641770
Participant

READEXCEL

Hi all I am using the readexcel function in mathcad prime 6.0.0.0 and to even read in a number it comes in as not a scaler. is there a set format in excel that i am missing as you can see the number below comes in in brackets [1] as an example. I have tried both .xlsx and .xlsm file types both give me the same. 

 

note: the if function below is just an example to show I cant use the data brought in because of the [1] (brackets). 

 

BG_9641770_0-1616059781592.png

Thanks
Ben

1 ACCEPTED SOLUTION

Accepted Solutions

Re: READEXCEL

You should (ALWAYS) attach THE worksheet, or at least A worksheet, that demonstrates the problem.

Anyway, I can see that you DID NOT type the opening square bracket before ORIGIN. It isn't there for nothing.

This is what you should get,

LucMeekes_0-1616072087147.png

and attached Prime file has the expression as well.

 

ORIGIN is not a function, but a Mathcad/Prime system variable that defines the origin of indexing in matrices and vectors (arrays). By default it is set to 0 (meaning that the first element of vector V is V0, but it can be set to any value (in real Mathcad ) or to 0 or 1 (in Prime).

 

Success!
Luc

View solution in original post

8 REPLIES 8

Re: READEXCEL

(Apparently) READEXCEL reads in the data from the excel file as an array (or a 'vector' if you will). If you only read in a single number, it will be a on-element vector in Prime. That's what the square brackets indicate.

If you take the first element of that vector, you have your number.

If you type

[ORIGIN

At the end of calling the READEXCEL function, so immediatley after the closing bracket ) and before the  =

that should do it.

 

Alternatively you can take the element in your little program, by adding the [ORIGIN to the variable A.

Note that if you have a vector, you cannot compare it to a scalar (=single number).

 

Success!
Luc

Re: READEXCEL

Thanks Luc 

it hasn't appeared to work, still getting the [1]

 

BG_9641770_0-1616063805615.png

 

Re: READEXCEL

Doesn't work outside the bracket either 

 

BG_9641770_0-1616064142113.png

 

Re: READEXCEL

You should type

[ORIGIN

(Exactly that! A square bracket followed by  ORIGIN)

Immediately AFTER the ) of the expression, and BEFORE the =

 

The result should look like:

LucMeekes_0-1616066164572.png

Essentially what it does is indexing the vector obtained by the READEXCEL call, and taking/pointing to, the very first element of that vector.

 

Success!
Luc

Re: READEXCEL

Hi Luc 

 

I have tried the various combinations below and it doesn't appear to work, it returns the number as 0 when the actual input is 1.

 

the ORIGIN before or after returns 0 but the excel cell is 1 as shown below 

 

BG_9641770_0-1616066539277.png

 

thanks

ben 

 

Re: READEXCEL

Thanks Luc

its giving me an error below;

BG_9641770_0-1616067702377.png

can you attach a sheet?

 

thanks

Ben 

 

Re: READEXCEL

You should (ALWAYS) attach THE worksheet, or at least A worksheet, that demonstrates the problem.

Anyway, I can see that you DID NOT type the opening square bracket before ORIGIN. It isn't there for nothing.

This is what you should get,

LucMeekes_0-1616072087147.png

and attached Prime file has the expression as well.

 

ORIGIN is not a function, but a Mathcad/Prime system variable that defines the origin of indexing in matrices and vectors (arrays). By default it is set to 0 (meaning that the first element of vector V is V0, but it can be set to any value (in real Mathcad ) or to 0 or 1 (in Prime).

 

Success!
Luc

View solution in original post

Re: READEXCEL

Thanks Luc 

 

Thats Great!

Announcements
Check out the latest
Mathcad Tip
"PTC Mathcad 15 / Prime 1-6 Update."