Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Last time we wrote this function to classify soil layers. I need to show that in the plot can that be possible in mathcad ?. I need to connect the table with the plot . so it draws horizontal marker whenever the layer changes. or change colors ..any kind of change to make it possible for the reader to understand it changes layer type
Like (y ) will be both z and ztop to draw the plot .
z is the depth
ztop the thickness of the layers
Solved! Go to Solution.
Not sure but cold it be that you are looking for something like this
It would also be possible to color the various section according to their depth, but this would mean that we have to split both vectors i various subvectors and use them in the plot, which also means that you have a lot of entries (8) at both axis and would need to manually add or remove entries it the number of z.top values changes.
Prime 10 file attached
OK, upon rethinking I guess that two colors are all thats needed
Dear Werner,
Is it possible to merge these to programs together. I need to show the levels in the plot in the left , I couldn't do that because it shows error . instead of using only q12 I need to use The Qcza which contains all of the qcza...
I previously used z12 because it is the longest. So it is okay to use Qcza and z 12 not Z
I also have a mistake , I couldn't include the unit of the infinity
Unfortuantely, I couldn't open the sheet you sent because it is higher version than mine. I use prime 9
Thanks in advance
@YA_10963798 wrote:
Unfortuantely, I couldn't open the sheet you sent because it is higher version than mine. I use prime 9
What kind of Mathcad Prime (MP) licence do you have?
I note you're using programming, which implies that you're probably using a maintained (or educational) licence. If your Mathcad has a full maintenance licence, then you should be able to find somebody to talk to get your Prime upgraded to MP10.
I encountered this situation during a couple of my jobs, with at least one Mathcad being several versions behind the current one. A quick conversation with my project manager (PM) and a call to IT got me upgraded in all cases. (I checked with the PM just in case there was some configuration control issue behind not upgrading).
Stuart
Hi Stuart,
I use full maintenance license . That's good to know I will connect somebody to help me upgrade my mathcad version
To be honest, I'm afraid if I upgrade the version, I will lose what I have done . I'm in the middle of project and can't afford any risk. This is why I maintain working on prime 9
Thanks
see it shows mistake even when I use q12 .. is the version the reason ?
@YA_10963798 wrote:
see it shows mistake even when I use q12 .. is the version the reason ?
I don't think so. The error likely arises because you are trying to stack a 2-column array ([qi zi]) onto a 4-column array (QZ). Is there a reason you have a separate column for Pa and M? Guessing that you only meant to have the q and z columns (from the stack(q[i, z[i) expression that gave the error), I removed the Pa and m columns, and the function seems to work OK with z12 - see function with green highlight.
Stuart
Quick Tip 1: If you're hitting problems with "dimensions", step back and think about which "dimension" Mathcad is referring to in any particular case - quantities or arrays!
Quick Tip 2: If you're getting a problem that's making you pull your hair out, try "try" to catch the error(s) and return the values of interest. I've often picked up errors by that way. You can see that I'd added the extra Pa and m columns to the expression stack(q[i, z[i).
Stuart,
Where to find (try function) sorry for the stupid question;)
And I wrote the same program like yours ( in green highlighted box) and still didn't work .
@YA_10963798 wrote:
Stuart,
Where to find (try function) sorry for the stupid question;)
And I wrote the same program like yours ( in green highlighted box) and still didn't work .
(Edited to add screenshot)
It's not quite the same. You've still got the extra Pa and m columns in the initial value of QZ, ie you've got 4 columns instead of the 2 to match stack(q[i,z[i).
It might be less visually confusing if you remove the units from the NaN. (Just checked, and it turns out units aren't necessary with NaNs, Mathcad seemingly being smart enough to treat them as having a universal unit.
Stuart
yes , you are right thank u
last question;
horizontals are undefined here, how did Werner make them defined and showed them in the plot in his answer
@YA_10963798 wrote:
yes , you are right thank u
last question;
horizontals are undefined here, how did Werner make them defined and showed them in the plot in his answer
Did you use the horizontals program that Werner used?
Werner's program is dimensionless and assumes that you've entered MPa for the qlevel columns. If you want, you could add the extra expression I've shown to the program, placing it just before the final R. You could leave the x-axis units as Pa or change them all to MPa; (the depth is in metres anyway, so no change needed).
Stuart
Thanks it works
@StuartBruff wrote:
@YA_10963798 wrote:
Stuart,
Where to find (try function) sorry for the stupid question;)
And I wrote the same program like yours ( in green highlighted box) and still didn't work .
(Edited to add screenshot)
It's not quite the same. You've still got the extra Pa and m columns in the initial value of QZ, ie you've got 4 columns instead of the 2 to match stack(qi,zi).
It might be less visually confusing if you remove the units from the NaN. (Just checked, and it turns out units aren't necessary with NaNs, Mathcad seemingly being smart enough to treat them as having a universal unit.
Forget what I said about removing units. Mathcad's not quite as smart as I thought it was when it comes to using mixed units in an array.
Here's the (re)corrected qlevels function.
When plotting the Yellow qlevels function result, use column 3 not column 2 for depth - column 2 is just NaNs. You get the same result as shown above when using the correct columns.
Because there is that discontinuity in the plot, I sighed manfully, opened Werner's worksheet, copied his splitIn2 function and renamed it to qlevels ... and happily (for me, anyway) got the same result. He also just uses the 2 columns.
Stuart
@YA_10963798 wrote:
Stuart,
Where to find (try function) sorry for the stupid question;)
Sorry, I missed the first part of your message. try is under the Programming dropdown in the Math tab in the Ribbon. Alternatively, use the keyboard shortcut ctrl-[, or type try then ctrl-j.
ctrl-j is one of Prime's outstanding contributions to humanity. It converts a typed name into the Mathcad programming construct of the same name. Saves no end of effort using the menu or trying to remember the keyboard shortcut. 👍
Although there is still much that Prime lacks compared to (original) Mathcad 15, I will also, under threat of torture, admit that Prime's array entry and editing methods are superior to those of the original. Just don't tell anyone I said so - I have my reputation to think of.
Stuart
No problem, Yusra.
Could you please clarify something, please?
What is your intention in plotting so many overlapping pressure v depth results? It seems visually confusing to me (a non-expert in your field), but it may be pretty standard in your line of work or quite understandable to the trained eye.
Stuart
and when I use the yellow highlighted box I get this
The unit-corrected Green qlevels function I posted works, but if you want to use the Yellow version, then the depth data is in column 3, not column 2. Yellow column 2 is full of NaNs.
Better always state the version of Prime you are using.
I guess the errors you made were already corrected by Stuart.
You misinterpreted the 1x2 matrix with the units as a 1 x 4 matrix. I used the implicit unit multiplication (Ctrlk-Shif-U) and not an explicit multiplication sign between NaN and the units.
You missed the unit meter for the infinity "value".
But it still does not make much sense to use the full combined vector Q.cza as first argument and the vector z[12 as the second one, as only a small part of the plot would show.
You would have to use the combined vector Z as second argument, but probably my program would fail because it assumes the values in the second argument to be sorted by size. So it would be needed to change the function splitIn2 to cope with a vector z where sorted vectors are stacked and separated by NaN's.
Instead if doing so, I wrote a separate function splitAll which you can call with q.cza and z which loops through the vectors,uses the original splitIn2 function and stacks the 14 results one on top of the other:
Prime 9 file attached
That is exactly what I needed . Thank you so much
Can you tell me where is my mistake ..
When I wrote it for the first part (7A) I got the same plot
When I tried it with the second part 7B I couldn't figure out where I mistaken to get different plots
Thought it could be nice to indicate the various depths that way
Of course you can combine this with the other two ways, drawing horizontal lines and drawing the traces in different colors.
Prime 9 sheet attached
wowww that's impressive
thank you so much
Terribly sorry about this, Werner, but I just couldn't help it ...
I'm embarrassed to admit that I have a fetish for functions and strongly believe in local functions for local programs, So I felt compelled to modify your Ar program.
It's a matter of swings and roundabouts as to which form is more readable and understandable with such a short program. However, even with brief program fragments, I usually find it helpful to use local functions to hide the nitty-gritty and show the essentials of what's happening. In this case, because the value of Qcza is independent of the i loop and ztopi and ztopi+1 are used twice, the Rect function was too tempting to leave alone; hence, the local function rect appeared. The rest of the program line simply called for it to be wrapped in the descriptively named addlayer. Then min and max Qcza complained about calculating the same value every time, so they had to be whisked out into minQ and maxQ.
I added horizontal and vertical markers to the plot (As you suggested, but before I read your suggestion. One day, I will learn to read things before diving in like a mad bull on a sugar high in a china shop. It will save me a lot of time.). The markers have appropriate expressions in their numerical placeholders rather than having fixed values.
It took me some time to spot that you'd changed the min Z to 35 m. I spent that time wondering why your plot looked different to mine after I'd edited the Ar program!
I changed n to 16 because the gaps between lines were a bit too obvious on my screen (possibly because my Dell has a 3840x2160 display).
Alas, a compulsive's work is never done.
And I wonder where the day goes ... 😀
Stuart
No need to be sorry or embarrassed.
I am aware that my Ar (had "Areas" in mind, I guess) is just a quick hack and would hardly win a prize for elegance and beauty 😉
Normally I think I would have provided a function with arguments x - and y-vectors of vectors and the z.top vector. But I didn't take the trouble to embellish the thing after the first successful test attempt.
Meaningful local functions and variables sure enhance readability a lot.
As for the horizontal lines I mentioned I had not in mind the plot's markers but rather the "horizontal" (or later "hor") data structure which was my first answer to the desire to visualize the different layers.
Prime's markers can't be automated that way, at least not concerning their numbers depending on the number of elements in z.top.
Changing the axis min/max values was a just fast way to achieve a zoom option - actually its the only way to do it in Prime as we don't have the visual zoom-option using the mouse as we had in Mathcad.
BTW, I use a 4K display, too, but on a 15,6" notebook screen. Still I noticed that the individual lines are visual in the zoomed in display but I did not care 😉 I thought that omitting the lines with the NaN's which separate the individual lines would make it significantly denser but that was not the case. We could remove them nonetheless in case of simple rectangles.
Using a 4K resolution with a small screen seems to be the reason why I can't use Primes Chart component. Of course the Windows zoom is set to a rather large value (the recommanded 250%). Most applications act and zoom their UI accordingly or can be persuaded to do so via the compatibility tab in their properties context menu, but the chart component doesn't and so the menus and especially the numbers on the plots are far too small even when set to the largest size possible. Apart from this and the fact that the component is rather a troublesome foreign body (a Prime add-in which does not support units!!!???) the component is far too slow reacting and is preventing fluid working. As someone here said it a while ago - if feels like having to operate the program with a pair of boxing gloves. Sure no fun.
BTW, you're not the only one who wonders where the day(s) have gone in the face of time flying by far too quickly...
@Werner_E wrote:
No need to be sorry or embarrassed.
I am aware that my Ar (had "Areas" in mind, I guess) is just a quick hack and would hardly win a prize for elegance and beauty 😉
Normally I think I would have provided a function with arguments x - and y-vectors of vectors and the z.top vector. But I didn't take the trouble to embellish the thing after the first successful test attempt.
Meaningful local functions and variables sure enhance readability a lot.
As for the horizontal lines I mentioned I had not in mind the plot's markers but rather the "horizontal" (or later "hor") data structure which was my first answer to the desire to visualize the different layers.
Prime's markers can't be automated that way, at least not concerning their numbers depending on the number of elements in z.top.
Changing the axis min/max values was a just fast way to achieve a zoom option - actually its the only way to do it in Prime as we don't have the visual zoom-option using the mouse as we had in Mathcad.
I'd guessed that was the case. Occasionally, I come to my senses and apply the old adage "If it ain't broke, don't fix it". Usually, after I've tinkered with it and broke it, I have to admit. 🙂
And, with regard to automating things Mathcad, I've spent a very frustrating couple of days trying to get Advanced Controls to sit up and beg. Partly, it's because I don't know JScript very well or how the controls integrate JScript into their workings. But mostly, it's because I can get neither the degree of interaction I want between them nor (easily) automate their replication. I might be able to do something working through the Mathcad API, but hides what's going on from the worksheet reader and involves further scripting.
@Werner_E wrote:
BTW, I use a 4K display, too, but on a 15,6" notebook screen. Still I noticed that the individual lines are visual in the zoomed in display but I did not care 😉 I thought that omitting the lines with the NaN's which separate the individual lines would make it significantly denser but that was not the case. We could remove them nonetheless in case of simple rectangles.
We have a similar set up. I'm using a Dell 5540 15.6" laptop, i7 with 32 GiB RAM.
@Werner_E wrote:
Using a 4K resolution with a small screen seems to be the reason why I can't use Primes Chart component. Of course the Windows zoom is set to a rather large value (the recommanded 250%). Most applications act and zoom their UI accordingly or can be persuaded to do so via the compatibility tab in their properties context menu, but the chart component doesn't and so the menus and especially the numbers on the plots are far too small even when set to the largest size possible. Apart from this and the fact that the component is rather a troublesome foreign body (a Prime add-in which does not support units!!!???) the component is far too slow reacting and is preventing fluid working. As someone here said it a while ago - if feels like having to operate the program with a pair of boxing gloves. Sure no fun.
I double-click on the Chart Component and open up the CC's edit box. The numbers are much easier to read there (IME). And you can change the font size for each axis independently. Here's a screenshot of before and after tinkering with the font size (14 pt)
@Werner_E wrote:
BTW, you're not the only one who wonders where the day(s) have gone in the face of time flying by far too quickly...
I expect that has been true since hominids first became aware of the passage of time. ☹️
Stuart
I guess the numbers are similar tiny in your setup as they are in mine.
Here with Mathcad Unimath Prime Font in the largest size accepted (20 pt), Boldface at the y-axis.
Compared to the native plots (where we unfortunately can't control the size of the numbers) its still a bit tinier.
Given that this is the max size achievable, that's not acceptable. The numbers look much larger when using Prime on a machine/display with a lower resolution, or better said: with a lower value for the Windows zoom factor.
The Chart Component's plots sure should look the very same regardless the windows zoom chosen.
And I always felt that the numbers in the native plot are a bit too tiny, especially when we have to fiddle around trying to change the axis limits.
BTW, I also have chosen the thickest (!) line width for the plot in the chart component!!
It took the Chart Component about 25+ seconds to come up after double clicking the already existing region. OK, I had the machine doing some recoding work in the background. Stopping all other processes (as far as possible) it still took 6 seconds which is far too much IMHO. Especially given that there is not indication that anything is going on, just the region going gray and freezing.
Richard (Jackson) once wrote here that the third party software itself is a pretty good one, one of the best, and provided some links. So the catastrophe we experience in Prime with this component doesn't seem to be their fault.
I agree with everything you said.
The Chart Component response time and user-feedback on opening is poor.
The inability to specify the Plot axis number/label size is a grievous omission. Screen resolutions are improving and allow better use of the available screen space, within reason (for values of reason). I run full resolution on my MacBook Pro, as well, and on my 10.2" iPad when using it as a 2nd screen. I don't know how I used to cope with just FHD. 🤔 And don't mention CGA ... I remember thinking my swanky new VGA B&W monitor was the bee's knees when I bought it. How time flies yet again! My sons now have my old Atari ST 512, Sinclair QL and Amstrad PC 2086 (*) - Industrial archaeology at its best 😀
Another particularly annoying problem I have with Plots is not being able to add a custom colour to the standard pallette. If i like a colour, I have to write out its hex values so that I can remember how to implement the colour the next time I want it. Naturally, I will have no idea where I've noted the colour.
A long-standing feature request, that probably resides in a PTC File 13 folder somewhere, is the ability to save an plot image to a matrix for further processing or documentation. You can at least save a Chart plot as a png, although I'd prefer to do it from a right-click context menu rather than having to open up the Chart Application.
Also, given Richard's comments, if it's not already used for the Plot component, I wonder why it isn't. It seems more capable and has a 2nd Y-axis - very useful.
Chart | XY Plot |
Plotting large data sets in chart components can affect performance.
To help you minimize this effect, the following limitations are built-in:
•The maximum number of traces is 50 per chart component
•The maximum number of plotted data points is 2,000,000 per trace
•Charts that have at least one trace with more than 50,000 points lose their selection layer in the chart application
Additionally, when plotting large numbers of symbols, you can benefit from using the following Symbols settings:
•Shape: Square
•Thickness: Thinnest option
•Weight: 1 px
•Opacity: 100%
|
Using an XY plot, PTC Mathcad can plot up to two million data points. n points vs capability: 5000 – 49999 50000 – 2000000 |
Stuart
(*) I think I ran my first version of Mathcad on the Amstrad. Then again, I've bought and built so many computers over the years, it could have been anything of that era.
According using the third party tool for the native plots, I guess if PTC's programmers would have been able to do so, they woiuld have done. Instead we have an "integration" like the one we experience now.
According the native plots, I vaguely remember that some PTC guy posted that improvement of the native plots still is on the todo list of PTC. Not sure if that meant the 3D plots (which really would need a lot of improvement) or the 2D plots as well.
Another problem I experienced when I implemented the last layer-identification approach with the hatched background was, how to define the order the traces are plotted (the filled rectangle must be plotted first, of course).
In Mathcad it was clear (while not really convenient if you wanted to add a plot which should be plotted before all others) - the order the expressions were placed was the order the traces were plotted.
In Prime it looks like its the order in which the traces were defined. So if you create a new plot and place it in front of another, the new one is still plotted last. I like in Prime that we can rearrange plots, add plots before or after an existing one and the existing one will still hold the color and other properties it was assigned. But I think an option to have control over the order the traces were processed by the graphics engine would be a welcome tool.