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

The community will undergo maintenance on October 16th at 10:00 PM PDT and will be unavailable for up to one hour.

READEXCEL

BG_9641770
11-Garnet

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

ACCEPTED SOLUTION

Accepted Solutions
LucMeekes
23-Emerald III
(To:BG_9641770)

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
LucMeekes
23-Emerald III
(To:BG_9641770)

(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

Thanks Luc 

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

 

BG_9641770_0-1616063805615.png

 

Doesn't work outside the bracket either 

 

BG_9641770_0-1616064142113.png

 

LucMeekes
23-Emerald III
(To:BG_9641770)

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

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 

 

Thanks Luc

its giving me an error below;

BG_9641770_0-1616067702377.png

can you attach a sheet?

 

thanks

Ben 

 

LucMeekes
23-Emerald III
(To:BG_9641770)

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

Thanks Luc 

 

Thats Great!

Announcements

Top Tags