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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Basic If Functions Applied to Arrays Derived from Spreadsheet Data

JJ_9094500
4-Participant

Basic If Functions Applied to Arrays Derived from Spreadsheet Data

I'm fairly new to the use of arrays and matrices in general. I'm in the crane design industry and modern codes require multiple load combinations to be analysed in structural calculations simultaneously. Codes then often pose choices based on things like stress ratios. For example, in it's simplest form, a different set of rules are required if a stress is in compression rather than in tension. I need the ability to automatically differentiate between these stresses, and the correct rules are applied for each load combination. Sometimes these problems may use array sizes in the hundreds. I've attached a very basic programme. My desired outcome is a single n x 1 array. What I tend to get is an array of nested arrays. I've played around and found that if I were to transpose this and turn the nested array into a single clean matrix, use the diagonal function, then this would give me what I need. I have no idea how to do this though. Help would be greatly appreciated.

ACCEPTED SOLUTION

Accepted Solutions
ttokoro
20-Turquoise
(To:JJ_9094500)

3 REPLIES 3
ttokoro
20-Turquoise
(To:JJ_9094500)

image.pngimage.png

 

image.pngimage.png

JJ_9094500
4-Participant
(To:ttokoro)

Thank you!

StuartBruff
23-Emerald III
(To:JJ_9094500)

For those with only Mathcad Prime Express, here's an Express 7 solution:

 

StuartBruff_0-1643444224318.png

 

StuartBruff_1-1643444260975.png

 

Stuart

 

Note: this would have been a lot easier if "if" was a true function that could be vectorized over. That way, the vectorized operator could be contained within prog1 and prog2 instead of needing to be defined as first scalar functions (_prog1 and _prog2) and then as (vectorized) array functions.

 

Help says the same thing that it has done since Mathcad first crawled out of the sea: "if is a (PTC) Mathcad control operator, not a function, and it does not work with operators that modify functions, such as the vectorize operator.".  Which explains everything and nothing.

 

 

Announcements

Top Tags