Skip to main content
1-Visitor
July 3, 2013
Solved

Finding incremental values with a loop

  • July 3, 2013
  • 1 reply
  • 5730 views

Hi,

I'm new to Mathcad and I've been struggling with a problem and wondered if someone could help. I'm using Mathcad to work out Response Spectra for particular ground motion.

I'm running a loop of linear acceleration method to find the displacement from ground acceleration. I can run successfully when I look at 1 value for the natural period and then from this I take the maximum absolute value. however, ideally I would like to be able to run at once for various different values of natural period (T) in the attached file. I will have to work out about 1000 of them so need to find a loop to be able to do it. I thought I might be able to do it as a range but I don't think that's possible.

I've attached the file and added the ground motion which is about 1600 values but felt it would be best to include.

Sorry if this is quite elementary but struggling with it and would be very grateful if anyone could help.

Thanks

Andrew

Best answer by Werner_E

I am not sure from your description what you are trying to do, but the error in your sheet is thrown because you had set ORIGIN to be 1 but used vector index 0 in your program.

1 reply

Werner_E25-Diamond IAnswer
25-Diamond I
July 3, 2013

I am not sure from your description what you are trying to do, but the error in your sheet is thrown because you had set ORIGIN to be 1 but used vector index 0 in your program.

1-Visitor
July 3, 2013

Thanks for that, the reason I had done that was that I was encountering a problem when I tried to do the range from 1..50 then when the denominator was T it said couldn't divide by zero even though my range should have started from 1. Is there another way to get round this?

I realise it's not very clear so I'll try to explain slightly better...

I can run the programme when I put T=1, which will give me the displacement at all 1600 points of which I only want the maximum absolute value. However, what I really want to do is to be able to write a programme that will allow me to get the max absolute value when T=0.02,0.04....20. Which would just give me the max abs value of displacement for each value of T.

Do you know if that is possible at all?

Thanks for your help, I really appreciate it.

25-Diamond I
July 3, 2013

Sure, it has to be possible.

But you cannot expect a routine which is written for a scalar T to work for a vector T, as you did.

The easies way in my opinion would be to write an additional loop inside your program that cycles through all values of T. You would have to put the caclculations of all variables which depend on T inside this program loop.

That way you could return a 1560x1000 matrix, but if you are anly after the maximum I would rewrite the program to just remember the max after each iteration and return the max only.

Is there a reason you use square root of uuu^2 rather than the absolute value of uuu?