Skip to main content
1-Visitor
June 30, 2017
Solved

LPSD from matlab to mathcad 14

  • June 30, 2017
  • 2 replies
  • 4609 views

Hi!

I have been trying to convert a matlab function into mathcad 14. The function is attahced in matlab format.(lpsd.m)

During this convertion i have found some difficulties with a native matlab functions. The BSXFUN.

If you check that lpsg.m file you can see the bsxfun function inside a for cycle. Does anyone have any idea how can I solve this?

 

thanks for your time people!

Cheers!

Best answer by Werner_E

Here are my attempts to duplicate bsxfun(@plus, A, B) and bsxfun(@times,A,B):

Bild1.PNG

2 replies

23-Emerald IV
June 30, 2017

If you look up what BSXFUN in Matlab is supposed to do, you'll find that it applies the operator indicated with the first argument to the two arrays in the second and third arguments.

IF A and B are arrays of equal size (length), then Matlab:

C = BSXFUN(@plus, A, B)

would be in Mathcad:

C:= A + B.

 

Success!
Luc

1-Visitor
June 30, 2017

Hi LucMeekes,

yes, i know what it does.

My problem is whenever A and B are matrices with difernet sizes. You can not sum or do anything like that.

23-Emerald IV
June 30, 2017

You cannot (mathematically correctly) add matrices or arrays of different sizes. It makes no sense.

So make sure they are of equal size and shape before you do the operation.

 

Success!
Luc

23-Emerald I
June 30, 2017

I think this may be a start.  Image here, trying to attach the file.

bsxfun.JPG

 

 

23-Emerald I
June 30, 2017

So I can't paste an image from the clipboard.

 

And you have to zip a file to post it--the app doesn't automatically create the zip.

 

THIS IS SOOOOO MUCH BETTER!