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:
mldivide error

Subject: mldivide error

From: Adam Lord

Date: 12 Jan, 2011 17:23:04

Message: 1 of 7

Hi all,

I am attempting to plot a graph with the following lines of code:

G_cur = 1/(l+(K_us.*(v_x.^2)./g));

plot(v_x,G_cur,'g+');
xlabel('v_x (m/s)')
ylabel('G cur (1 / m rad)')

but I am faced with this error (which I do not really understand):

??? Error using ==> mrdivide
Matrix dimensions must agree.

Error in ==> Car_B_Q2c at 14
G_cur = 1/(l+(K_us.*(v_x.^2)./g));

Does anyone have a suggestion for how I can fix it? I have tried several combinations of brackets and dots but nothing seems to work.

Thanks
Adam

Subject: mldivide error

From: Wayne King

Date: 12 Jan, 2011 17:33:04

Message: 2 of 7

"Adam Lord" <adamtlord@gmail.com> wrote in message <igko1o$qal$1@fred.mathworks.com>...
> Hi all,
>
> I am attempting to plot a graph with the following lines of code:
>
> G_cur = 1/(l+(K_us.*(v_x.^2)./g));
>
> plot(v_x,G_cur,'g+');
> xlabel('v_x (m/s)')
> ylabel('G cur (1 / m rad)')
>
> but I am faced with this error (which I do not really understand):
>
> ??? Error using ==> mrdivide
> Matrix dimensions must agree.
>
> Error in ==> Car_B_Q2c at 14
> G_cur = 1/(l+(K_us.*(v_x.^2)./g));
>
> Does anyone have a suggestion for how I can fix it? I have tried several combinations of brackets and dots but nothing seems to work.
>
> Thanks
> Adam

Hi Adam, you should give us the sizes (dimensions) of K_us, v_x, and g.

Wayne

Subject: mldivide error

From: Adam Lord

Date: 12 Jan, 2011 17:42:05

Message: 3 of 7

Hi Wayne,

My full code is below - hopefully that should explain what you need to know

Thanks,
Adam

% Car B (Oversteer)
% Curvature gain plot
m = 1355;
I_z = 1912;
l_F = 1.324;
l_R = 1.052;
l = l_F + l_R;
C_F = 45336;
C_R = 56492;
K_us = -6.502*10^-4;
g = 9.81;
v_x = 5:50; % Values between 5m/s and 50m/s

G_cur = 1/(l+(K_us.*(v_x.^2)./g));

plot(v_x,G_cur,'g+');
xlabel('v_x (m/s)')
ylabel('G cur (1 / m rad)')

Subject: mldivide error

From: Sean de

Date: 12 Jan, 2011 17:47:07

Message: 4 of 7


You need a dot in front of the _first_ division sign.
> G_cur = 1/(l+(K_us.*(v_x.^2)./g));

Subject: mldivide error

From: Adam Lord

Date: 12 Jan, 2011 17:52:04

Message: 5 of 7


> You need a dot in front of the _first_ division sign.
> > G_cur = 1/(l+(K_us.*(v_x.^2)./g));

Yeah I tried that already and I'm still getting this error

??? Error using ==> mrdivide
Matrix dimensions must agree.

Error in ==> Car_B_Q2c at 14
G_curB = 1/(l+(K_us.*(v_x.^2)./g));

Subject: mldivide error

From: Sean de

Date: 12 Jan, 2011 17:59:05

Message: 6 of 7

"Adam Lord" <adamtlord@gmail.com> wrote in message <igkpo4$feb$1@fred.mathworks.com>...
>
> > You need a dot in front of the _first_ division sign.
> > > G_cur = 1/(l+(K_us.*(v_x.^2)./g));
>
> Yeah I tried that already and I'm still getting this error
>
> ??? Error using ==> mrdivide
> Matrix dimensions must agree.
>
> Error in ==> Car_B_Q2c at 14
> G_curB = 1/(l+(K_us.*(v_x.^2)./g));

The FIRST division sign!!!!

And it is your error, I ran it.

Subject: mldivide error

From: Wayne King

Date: 12 Jan, 2011 18:02:05

Message: 7 of 7

"Adam Lord" <adamtlord@gmail.com> wrote in message <igkpo4$feb$1@fred.mathworks.com>...
>
> > You need a dot in front of the _first_ division sign.
> > > G_cur = 1/(l+(K_us.*(v_x.^2)./g));
>
> Yeah I tried that already and I'm still getting this error
>
> ??? Error using ==> mrdivide
> Matrix dimensions must agree.
>
> Error in ==> Car_B_Q2c at 14
> G_curB = 1/(l+(K_us.*(v_x.^2)./g));

Hi Adam, This will fix your problem:

G_cur = 1./(1+(K_us*(v_x.^2))/g);
plot(v_x,G_cur,'g+');
xlabel('v_x (m/s)')
ylabel('G cur (1 / m rad)')

Wayne

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