Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
Hi dear, I'm having trouble with the "for" loop when I create a function and try to graph a spectrum as a function of time.
I have MathCAD version 11. It worked in the old version, but in this latest version, it shows me an error message stating that the variable T is not defined.
Why is this happening?
Solved! Go to Solution.
It worked in the old version, but in this latest version, it shows me an error message stating that the variable T is not defined.
Why is this happening?
What you did worked OK up to version 9 of Prime.
You are using an undocumented trick which turned a range into a vector - the inline evaluation (the = at the end) did the trick.
So up to Prime 9 variable T was now a vector, but starting with Prime 10 this variable still is just a range and that's the reason your sheet is failing.
As Alan already said you have to define "T" as a vector and there are many ways you could do so.
The easiest way is to use the new function "vec" (it was introduced with Prime 11).
Simply replace your definition of "T" with T:=vec(0s,0.01s,Tmax) and your sheet should again be up and running.
But actually I wonder why you would go through the hassle of using vectors at all. You are using a math program, not just a spreadsheet like Excel. So there is no need to manipulate vectors - you could rather use functions to do the job - much more versatile:
You have constructed T as a range variable. It needs to be a vector.
As I only have the Express version I've done your worksheet without the programming structure. However, your loop should work ok if you make the change from range variable to vector.
Please upload your worksheet next time - not just an image.
Hi AlanStevens
sorry for not responding sooner, as I was unwell, I have , I have some questions regarding the use of i:1...500, Ti:i/500*Tmax. Why did you use this method? Could you explain?
Thanks
Its another way to create a vector T.
Note that Alan's sheet uses ORIGIN=0.
It seems from your picture that you are suing ORIGIN=1.
So to create the same vector T as you would using T:=vec(0s,0.01s,Tmax) you could use
or
The "vec" function is not available in Prime 10 (and below) and furthermore its a 'Premium' function and so not available in the free Express version which was used by Alan.
It worked in the old version, but in this latest version, it shows me an error message stating that the variable T is not defined.
Why is this happening?
What you did worked OK up to version 9 of Prime.
You are using an undocumented trick which turned a range into a vector - the inline evaluation (the = at the end) did the trick.
So up to Prime 9 variable T was now a vector, but starting with Prime 10 this variable still is just a range and that's the reason your sheet is failing.
As Alan already said you have to define "T" as a vector and there are many ways you could do so.
The easiest way is to use the new function "vec" (it was introduced with Prime 11).
Simply replace your definition of "T" with T:=vec(0s,0.01s,Tmax) and your sheet should again be up and running.
But actually I wonder why you would go through the hassle of using vectors at all. You are using a math program, not just a spreadsheet like Excel. So there is no need to manipulate vectors - you could rather use functions to do the job - much more versatile:
Hi Werner_E,
sorry for not responding sooner, as I was unwell, but your answer was the most viable.
