Get Help

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Re: READEXCEL

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-18-2021
05:30 AM

03-18-2021
05:30 AM

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).

Thanks

Ben

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-18-2021
08:58 AM

03-18-2021
08:58 AM

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,

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

8 REPLIES 8

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-18-2021
06:30 AM

03-18-2021
06:30 AM

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-18-2021
06:37 AM

03-18-2021
06:37 AM

Re: READEXCEL

Thanks Luc

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-18-2021
06:42 AM

03-18-2021
06:42 AM

Re: READEXCEL

Doesn't work outside the bracket either

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-18-2021
07:11 AM

03-18-2021
07:11 AM

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:

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-18-2021
07:23 AM

03-18-2021
07:23 AM

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

thanks

ben

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-18-2021
07:42 AM

03-18-2021
07:42 AM

Re: READEXCEL

Thanks Luc

its giving me an error below;

can you attach a sheet?

thanks

Ben

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-18-2021
08:58 AM

03-18-2021
08:58 AM

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,

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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

03-18-2021
09:02 AM

03-18-2021
09:02 AM

Re: READEXCEL

Thanks Luc

Thats Great!