Skip to main content
1-Visitor
February 21, 2011
Solved

loops, matrices and coupled equations

  • February 21, 2011
  • 12 replies
  • 6023 views

Hi everybody,

with the help of Stuart Bruff I managed to get the file I uploaded here. Now I have a task, but don`t know if it is possible in MathCad, and when it is - how...

I wish to iterate the four constants (kic, kisc1, kisc2 and kQ) over a certain range, solve the set of equations and write the matrix (kic kisc1 kisc2 kQ Rqt) for each possible set of these k`s into a file. What I managed up to now is the variation of all k`s with l1, but I want to change them independently. My first try was to use several for-loops (one for each k), but I had too many problems and nothing did work, so I have nothing to show here.

Can anybody tell me if I should try further on, or if I can stop because it isn`t possible at all?

Thank you in advance,

Katharina

Best answer by StuartBruff

Katharina Hunger wrote:

Hi Stuart,

I can open the file now. Thank you! I will have to have take a closer look to try to understand what you did there.

But this I recognised immediately: the first array in the for-loop is red and I get this message:"The expression to the left of the equal sign cannot be defined."

I tried to define arrays this way before, and also got this message. I thought that I did something wrong and that I have to define arrays some other way in a program, but now I fear that it is a problem of me using the student version and not the professional version. Is that possible?

Greetings,

Katharina

Hi Katharina,

I'm not sure what you're seeing, but I dug out a copy of M2000. It doesn't like the parallel assignment, so I replaced it with a line-by-line approach as, I think, was intended for the programming (there's no need for it in a for loop). It now works in M2000, so it should work in M2001; I don't think it being a Student Edition makes a difference.

Stuart

12 replies

23-Emerald V
February 21, 2011

Katharina Hunger wrote:

Hi everybody,

with the help of Stuart Bruff I managed to get the file I uploaded here. Now I have a task, but don`t know if it is possible in MathCad, and when it is - how...

I wish to iterate the four constants (kic, kisc1, kisc2 and kQ) over a certain range, solve the set of equations and write the matrix (kic kisc1 kisc2 kQ Rqt) for each possible set of these k`s into a file. What I managed up to now is the variation of all k`s with l1, but I want to change them independently. My first try was to use several for-loops (one for each k), but I had too many problems and nothing did work, so I have nothing to show here.

Can anybody tell me if I should try further on, or if I can stop because it isn`t possible at all?

Thank you in advance,

Katharina

Hi Katharina,

I haven't had time to look at the bit of the worksheet that reads/writes from file, but is the bit at the bottom of the attached worksheet sort of what you're after for the iteration over variables?

It uses a utility function, vec, that I wrote to quickly generate sequences. I'm not sure if it works in your version of Mathcad. If not, it should be fairly easy to replace it.

This would probably be a lot easier, and more general, if Mathcad had a proper multi-dimensional array facility (particularly indexing), but a lot can be done with nested arrays.

Stuart

Katharina1-VisitorAuthor
1-Visitor
February 22, 2011

Hi Stuart,

unfortunately I again can`t open your file (MathCad 2001, Student Version).

When I started this project I had expected that MathCad can handle multi-dimensional arrays. But I guess I am not the first person who would like that 🙂

Greetings,

Katharina

23-Emerald V
February 22, 2011

Katharina Hunger wrote:

Hi Stuart,

unfortunately I again can`t open your file (MathCad 2001, Student Version).

When I started this project I had expected that MathCad can handle multi-dimensional arrays. But I guess I am not the first person who would like that 🙂

Greetings,

Katharina

Hi Katharina,

OK, I thought I had saved it in 2001 format. Try the attached. It's in M2000 format and I'm not sure how that will save some items ... it should be OK.

Stuart