Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Trouble with quad and multiplication (SOS)

Subject: Trouble with quad and multiplication (SOS)

From: Vivek Saxena

Date: 13 Apr, 2010 02:12:04

Message: 1 of 1

Hi,

I'm trying to evaluate a 1D integral, but every time I execute my code I get an error, which I've been unable to fix so far. I would appreciate if someone could help me correct it. I've been stuck at this point for some time.

Segment of Main Program (experiment.m):

359: fun2 = @(ksi)bstilde(ksi,ii,alpha,kappa,k_0,x1,x2,L_s,E_0);
360: bs_tilde(s,ii) = quad(fun2,0,1);

(here, ksi, ii, alpha,kappa,k_0,x1,x2,L_s,E_0 are all well defined. I've included the line numbers by hand)

Segment of bstilde function:

3: function f = bstilde(ksi,m,alpha,kappa,k_0,x1,x2,L_s,E_0)

5: N = ksi;
6: if (m == 1)
7: N = 1-ksi;
8: end

10: J = complex(0.,1.);
11: x = (1-ksi).*x1 + ksi.*x2;
12: f = alpha*(J*k_0 + 0.5*kappa - J*k_0*kappa.*x)*N.*L_s*E_0*exp(-J*k_0.*x);

Now, when I execute this, I get the following error:

??? Error using ==> mtimes
Inner matrix dimensions must agree.

Error in ==> bstilde at 12
f = alpha*(J*k_0 + 0.5*kappa - J*k_0*kappa.*x)*N.*L_s*E_0*exp(-J*k_0.*x);

Error in ==> @(ksi)bstilde(ksi,ii,alpha,kappa,k_0,x1,x2,L_s,E_0)


Error in ==> quad at 77
y = f(x, varargin{:});

Error in ==> experiment at 360
        bs_tilde(s,ii) = quad(fun2,0,1);


Eagerly awaiting a response. Thanks in advance!

-Vivek

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us