Quantcast
Channel: Latest Discussions - COMSOL Forums
Viewing all articles
Browse latest Browse all 5773

Call a MATLAB function

$
0
0

Hello every body,

I wrote a MATLAB fucntion for a spline curve and it worked fine in MATLAB. When calling the function to COMSOL, it gives the following error:

''Incorrect size of returned vector. 126 elements were expected, but the returned matrix was 1 x 1. ''

I know that COMSOL does not accept that function output 1x1, and it should be 126x126 instead. How to correct that? any help would be appreciated.

Here is my matlab function

function nurbs = nrbmak(coef,knots)

coefs = [0.0 1.5; 0.0 3.0];

knots = [0.0 0.0 1.0 1.0];

nurbs.form = 'B-NURBS';

nurbs.dim = 4;

np = size(coefs);

dim = np(1);

nurbs.number = np(2);

if (dim < 4)

nurbs.coefs = repmat([0.0 0.0 0.0 1.0]',[1 np(2)]); 

nurbs.coefs(1:dim,:) = coefs;   

else

nurbs.coefs = coefs; 

end

nurbs.order = size(knots,2)-np(2);

knots = sort(knots);

nurbs.knots = (knots-knots(1))./(knots(end)-knots(1));

nrbctrlplot(nurbs);

end


Viewing all articles
Browse latest Browse all 5773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>