From: Daniel on
I'm getting this error message:
??? Subscripted assignment dimension mismatch.
Error in ==> Untitl2 at 10

for this set up:
r = 3.5;
b = 5.5;
w = 4000:1000:8000;
% Compute and plot the Velocity %
for i = 1:length(w)
t = linspace(0,1/w(i),256);
for j = 1:length(t)
th = t(j)*w(i)*2*pi;
v(i,j) = -2*pi*w*sin(th).*r - (2*pi*w*sin(th).*cos(th).*r^2)./(sqrt(b^2 - r^2*sin(th).^2));
end
end
disp('Velocity v versus Time t'),disp(v)

Any help on how to resolve this? To say I'm new to Matlab is a GROSS understatement. Thanks in advance for any help.
From: Aman P.V on
If I understood your context correctly, I think you have forgotten to put w(i) in the for loop

You may also write the code using colon operator as follows

for i = 1:length(w)
t = linspace(0,1/w(i),256);
th=t*w(i)*2*pi;
v(i,:)=-2*pi*w(i)*sin(th)*r - ...
(2*pi*w(i)*sin(th).*cos(th)*r^2)./(sqrt(b^2 - r^2*sin(th).^2));
end

I hope it will serve your purpose
"Daniel " <xshagex(a)aol.com> wrote in message <hfeg9h$ofa$1(a)fred.mathworks.com>...
> I'm getting this error message:
> ??? Subscripted assignment dimension mismatch.
> Error in ==> Untitl2 at 10
>
> for this set up:
> r = 3.5;
> b = 5.5;
> w = 4000:1000:8000;
> % Compute and plot the Velocity %
> for i = 1:length(w)
> t = linspace(0,1/w(i),256);
> for j = 1:length(t)
> th = t(j)*w(i)*2*pi;
> v(i,j) = -2*pi*w*sin(th).*r - (2*pi*w*sin(th).*cos(th).*r^2)./(sqrt(b^2 - r^2*sin(th).^2));
> end
> end
> disp('Velocity v versus Time t'),disp(v)
>
> Any help on how to resolve this? To say I'm new to Matlab is a GROSS understatement. Thanks in advance for any help.
From: Daniel on
That's great thanks so much for the help.


"Aman P.V" <amanpv(a)gmail.com> wrote in message <hfej90$2uh$1(a)fred.mathworks.com>...
> If I understood your context correctly, I think you have forgotten to put w(i) in the for loop
>
> You may also write the code using colon operator as follows
>
> for i = 1:length(w)
> t = linspace(0,1/w(i),256);
> th=t*w(i)*2*pi;
> v(i,:)=-2*pi*w(i)*sin(th)*r - ...
> (2*pi*w(i)*sin(th).*cos(th)*r^2)./(sqrt(b^2 - r^2*sin(th).^2));
> end
>
> I hope it will serve your purpose
> "Daniel " <xshagex(a)aol.com> wrote in message <hfeg9h$ofa$1(a)fred.mathworks.com>...
> > I'm getting this error message:
> > ??? Subscripted assignment dimension mismatch.
> > Error in ==> Untitl2 at 10
> >
> > for this set up:
> > r = 3.5;
> > b = 5.5;
> > w = 4000:1000:8000;
> > % Compute and plot the Velocity %
> > for i = 1:length(w)
> > t = linspace(0,1/w(i),256);
> > for j = 1:length(t)
> > th = t(j)*w(i)*2*pi;
> > v(i,j) = -2*pi*w*sin(th).*r - (2*pi*w*sin(th).*cos(th).*r^2)./(sqrt(b^2 - r^2*sin(th).^2));
> > end
> > end
> > disp('Velocity v versus Time t'),disp(v)
> >
> > Any help on how to resolve this? To say I'm new to Matlab is a GROSS understatement. Thanks in advance for any help.