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

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Return (several) plots programmatically

snã¦ss
5-Regular Member

Return (several) plots programmatically

Hi!

Is it possible to return a plot in MC15 from a progam?

Background:

I have multiple excel files with data.

 

Using the READEXCEL i want to take the data for each file and plot a fitted curve (polyfit(X,Y,2)) for each file

 

I cannot find any commands to output a plot

 

Regards
Siggi

1 ACCEPTED SOLUTION

Accepted Solutions
LucMeekes
23-Emerald III
(To:snã¦ss)

Mathcad is not Matlab. That is: it is not a programming language.

Inserting a plot on a worksheet can only be done by user (interface) action.

 

What you can do is insert a plot, and adapt it to your needs. Then copy it as many times as you need on the worksheet and feed each plot with data from a file source (data file, excel file, whatever), by just changing the file name. That should work fine if all your file sources are structured similarly (if not equally).

 

Success!
Luc

View solution in original post

5 REPLIES 5
LucMeekes
23-Emerald III
(To:snã¦ss)

Mathcad is not Matlab. That is: it is not a programming language.

Inserting a plot on a worksheet can only be done by user (interface) action.

 

What you can do is insert a plot, and adapt it to your needs. Then copy it as many times as you need on the worksheet and feed each plot with data from a file source (data file, excel file, whatever), by just changing the file name. That should work fine if all your file sources are structured similarly (if not equally).

 

Success!
Luc

In Mathcad a plot is not an object which can be stored in a variable or can be the result of a function.
But you sure can write a program which takes the Excel file name and returns the desired function.

Not sure if the following example comes close to what you are looking for:

Werner_E_0-1599149890802.png

 

snã¦ss
5-Regular Member
(To:Werner_E)

Thank you @Werner_E  and @LucMeekes !

Quick follow-up regarding plots:

Is it possible to link the plot title to e.g. a vector containing the name of the files? 

 

So when I enter a new list of excel filenames, the plot titles would automatically update

 

snã¦ss_2-1599219992742.png

Regards
Siggi

 

 

 

LucMeekes
23-Emerald III
(To:snã¦ss)

Quick answer: No.

The plot title is not a variable accessible from within mathcad. It, like the rest of the plot, can only be entered through the user interface.

 

What you can do is, if the file name is a (string) variable, evaluate that variable above or on top of the plot.

 

Success!
Luc

As Luc already wrote you can't control those settings via worksheet variables.

 

An alternative to placing regions with evaluated variables to show filenames alongside the plot is, to place scripted textboxes above the plots. You have control over font size, color etc. that way.

Werner_E_1-1599256588766.png

When you open the attached worksheet you have to click "No" to allow the script to run.

 

 

 

Top Tags