Skip to main content
8-Gravel
September 3, 2020
Solved

Return (several) plots programmatically

  • September 3, 2020
  • 2 replies
  • 2263 views

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

Best answer by LucMeekes

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

2 replies

LucMeekes23-Emerald IVAnswer
23-Emerald IV
September 3, 2020

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

25-Diamond I
September 3, 2020

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ã¦ss8-GravelAuthor
8-Gravel
September 4, 2020

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

 

 

 

23-Emerald IV
September 4, 2020

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