Get Help

Showing results for

- Community
- :
- PTC Mathcad
- :
- PTC Mathcad
- :
- Matlab data to Mathcad

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Showing results for

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-17-2011
11:13 AM

08-17-2011
11:13 AM

Hi guys. I have an important question. I have a my full program of OFDM and a laser to modulate it in Matlab. its optical communication.

Now I have a solid complicated nonlinear Schrodinger equation that defines my optical fibre. To program it in matlab, it might take ages. Cause it concerns partial derivative and so on.

so I thought may be I can write that equation in Mathcad, and get the data across the laser to Mathcad. Do the math and get the values back to Matlab.

Is that possible?

thank you. If you have any suggestion on this or perhaps any tutorial, please share it with me. Thank you very much!

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
02:56 AM

08-18-2011
02:56 AM

Hello!

You can find a link to the guide "Developer's Reference" in "Mathcad Help" (F1 key):

Or use the direct link: C:\Program Files\Mathcad\Mathcad 15\doc\HELP_EN\DevRef\DevRef.htm

**P.S. **Also look in the Help topic "MATLAB Component". Quote: "In addition to importing and exporting MATLAB data files using the File Input, File Output, or Data Table components, you can also use the MATLAB component to execute MATLAB scripts using data from your Mathcad worksheet, and return the results to Mathcad."

27 REPLIES 27

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-17-2011
01:24 PM

08-17-2011
01:24 PM

Re: Matlab data to Mathcad

so I thought may be I can write that equation in Mathcad, and get the data across the laser to Mathcad. Do the math and get the values back to Matlab. Is that possible?

Yes. You need to call Mathcad from Matlab using the automation interface. See the Developers Reference under the help menu.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-17-2011
01:27 PM

08-17-2011
01:27 PM

Re: Matlab data to Mathcad

Hi Richard. Thanks for your reply. Where can I find this developers reference? Please advice. Thank you.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-17-2011
02:02 PM

08-17-2011
02:02 PM

Re: Matlab data to Mathcad

Look under the help menu in Mathcad.

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
02:56 AM

08-18-2011
02:56 AM

Hello!

You can find a link to the guide "Developer's Reference" in "Mathcad Help" (F1 key):

Or use the direct link: C:\Program Files\Mathcad\Mathcad 15\doc\HELP_EN\DevRef\DevRef.htm

**P.S. **Also look in the Help topic "MATLAB Component". Quote: "In addition to importing and exporting MATLAB data files using the File Input, File Output, or Data Table components, you can also use the MATLAB component to execute MATLAB scripts using data from your Mathcad worksheet, and return the results to Mathcad."

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
03:59 AM

08-18-2011
03:59 AM

Re: Matlab data to Mathcad

It depends which version of Matlab you are using. The Mathcad component won't accept the more recent versions of Matlab. I can't remember what versions it will work with, but certainly no version after (and including) 2008b. It might be easier to dump the data to a text or csv file, say, and transfer that.

Alan

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
05:41 AM

08-18-2011
05:41 AM

Re: Matlab data to Mathcad

Hi Alan. I have the most recent Matlab version. Do you know where I can find regarding this interface properties according to versions. Is it easy to do it over excel? Is it easy to import?

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
05:48 AM

08-18-2011
05:48 AM

Re: Matlab data to Mathcad

Is it easy to do it over excel? Is it easy to import?

Mathcad has built in functions which allow data to be written to Excel. There are also many scripted components which will allow this.

Mike

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
07:02 AM

08-18-2011
07:02 AM

Re: Matlab data to Mathcad

For data out of Mathcad look up WRITEPRN in the help file or investigate the Excel component.

For data into Matlab try 'help load' or 'help xlsread' within Matlab.

Alan

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
08:55 AM

08-18-2011
08:55 AM

Re: Matlab data to Mathcad

Guys. Thanks all for the quick response. Im using Mathcad 14. So I can save the data from Matlab to excel. Then import it to Mathcad. Do the calculations. Export it to excel and load or xlsread back to matlab.

Is the procedure right? Thanks again guys!!

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
09:00 AM

08-18-2011
09:00 AM

Re: Matlab data to Mathcad

So I can save the data from Matlab to excel. Then import it to Mathcad. Do the calculations. Export it to excel and load or xlsread back to matlab.

Is the procedure right? Thanks again guys!!

Yes that seems to work.

Mike

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
05:16 PM

08-18-2011
05:16 PM

Re: Matlab data to Mathcad

I was under the impression from your first post that Matlab is controlling the laser modulation, and as part of that control you want to pass data to Mathcad, do some calculations and get the answer back. So you would need something that is fully automated (no manual saving and loading of files, etc), and Matlab, not Mathcad, has to be in control. Is that correct?

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
05:21 PM

08-18-2011
05:21 PM

Re: Matlab data to Mathcad

hi Richard. After the laser modulation part. I can stop the process, grab the data, and run it in mathcad. And bring it back to Matlab. I thought It should be automated. But since its getting very complicated. I have to do the manual process.

Do you think I have an alternative? Thank you.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
05:29 PM

08-18-2011
05:29 PM

Re: Matlab data to Mathcad

hi Richard. After the laser modulation part. I can stop the process, grab the data, and run it in mathcad. And bring it back to Matlab.

OK. I see.

Do you think I have an alternative? Thank you.

Like I said, you can call Mathcad via the automation interface (i.e. as a COM object). Whether it's worth the effort of writing the code to do that depends on your level of experience calling things such as ActiveX controls (also COM objects) from within Matlab, and how many times you you are going to have to port data back and forth. There are not many steps required to push the data over and get the answer back.

Launch Mathcad (or link to it if it's already running)

Load the worksheet (if not already loaded)

Use the Worksheet.SetValue method to send the data over.

Use the Worksheet.Recalculate method to force recalculation

Use the Worksheet.GetValue method to get the answer back

Optionally, close the worksheet and/or Mathcad.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
05:53 PM

08-18-2011
05:53 PM

Re: Matlab data to Mathcad

Hi Richard. Sorry for asking this again. So the idea now is,

writing a code in Matlab. Which means it will call a function sort of Mathcad in this case. Which needs ActiveX or COM objects. What do meant by worksheet, I dont understand that part.

Now say I have ran until the laser. I wana bring the data to Mathcad, so I open Mathcad. In the same Matlab program, I define a function that delivers the particular data to Mathcad. Then go Mathcad, run it by myself. Then go back to matlab, and make it call the values back. Is excel involved in between any of this procedure?

Many thanks!

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
06:09 PM

08-18-2011
06:09 PM

Re: Matlab data to Mathcad

writing a code in Matlab. Which means it will call a function sort of Mathcad in this case. Which needs ActiveX or COM objects.

Matlab can call another piece of software if that software is COM compliant. Mathcad is COM compliant.

What do meant by worksheet, I dont understand that part.

The Mathcad "program" or "document"

Now say I have ran until the laser. I wana bring the data to Mathcad, so I open Mathcad. In the same Matlab program, I define a function that delivers the particular data to Mathcad. Then go Mathcad, run it by myself. Then go back to matlab, and make it call the values back. Is excel involved in between any of this procedure?

Not quite. Your Matlab program launches Mathcad, loads the correct worksheet, sends the data over, forces Mathcad to recalculate the worksheet, grabs the answer back, closes Mathcad. You do not have to do anything at all (other than write the Matlab code that does this, of course ). There is no need for Excel or any other piece of software.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
06:14 PM

08-18-2011
06:14 PM

Re: Matlab data to Mathcad

Hi Richard.... your wink looks a bit scary... i hope its not. Cause I got the idea of your explanation. But I got no idea how the code going to be. By chance, do you have any example? Cause I googled it, I cant really find proper information with sort of examples, other then Mathcad help notes in google.

Sorry if its too much too ask, if you dont mind sharing any if you have... But seriously thanks a lot!!

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
06:26 PM

08-18-2011
06:26 PM

Re: Matlab data to Mathcad

If I had an example I would have already posted it. I don't use Matlab though, so I don't have an example. I am 100% certain it can be done though. I can give you an example written in VBA, in which Excel calls Mathcad, but not a Matlab example. I think I know someone that might be able to provide such an example though. In fact, I'm kind of surprised he hasn't already commented in this thread. I'll send him an e-mail and ask him about it.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
06:40 PM

08-18-2011
06:40 PM

Re: Matlab data to Mathcad

Thanks Richard!! Im glad that I found this forum!!! Thanks a lot!!

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-19-2011
05:49 AM

08-19-2011
05:49 AM

Re: Matlab data to Mathcad

Richard prompted me: This is from an internal newsletter I wrote a while back

I tried to paste it (the content via cut & paste) in but it won't let me! so see the attachments.

http://collab.mathsoft.com/~Mathcad2000 has all the details - search for 'philip matlab' between 1 oct 2006 and 1 oct 2007 for some other threads

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-19-2011
09:12 AM

08-19-2011
09:12 AM

Re: Matlab data to Mathcad

Thanks Philip

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-19-2011
03:07 PM

08-19-2011
03:07 PM

Re: Matlab data to Mathcad

Thank you very much Philip. I will carry out from here. Thanks a lot everyone.

Richard, appreciate your help a lot!!

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
08:44 AM

08-18-2011
08:44 AM

Re: Matlab data to Mathcad

Don't worry about it. You are not using the Matlab component, which allows caling Matlab from Mathcad. You are going the other way: Matlab is calling Mathcad.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
10:23 AM

08-18-2011
10:23 AM

Re: Matlab data to Mathcad

True! However, because this would be a lot more complicated than simply inserting a pre-existing component, I suspect it would be far quicker to program the pde directly within Matlab (it's not that difficult to do - though it isn't as straightforward as in Mathcad). My vote is still for data transfer using the Excel component!

Alan

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
10:39 AM

08-18-2011
10:39 AM

Re: Matlab data to Mathcad

Hi guys. I look up on how to import data from Mathcad to Matlab... if any shortcuts... cheers guys!

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
05:04 PM

08-18-2011
05:04 PM

Re: Matlab data to Mathcad

Hi guys. I look up on how to import data from Mathcad to Matlab... if any shortcuts... cheers guys!

Unless your Mathcad version is compatible with the version of Matlab, I very much doubt you'll find a quicker way. Just set the Mathcad worksheet up so it can be used multiple time.

Mike

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
05:39 AM

08-18-2011
05:39 AM

Re: Matlab data to Mathcad

Hi VladimirN. Thanks for such detailed answer. Appreciate it a lot. I will try it on.

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Notify Moderator

08-18-2011
07:05 AM

08-18-2011
07:05 AM

Re: Matlab data to Mathcad

Which version of Mathcad you use?