MATLAB: More non-singleton rhs dimensions

singleton

I am getting an error here but I am not sure why.
I am trying to create a 1×5 matrix for the 5 c answers using the 5 t values in that matrix.
Thanks

Best Answer

I'm thinking that you want to loop through your t values. You first assign t to the vector [30,60,90,120,150] but then reassign it in your for loop to (1:5) or [1 2 3 4 5]. You instead need to index your values of t inside of your loop something like
x = (0:1:100)'
Ex = 0.02
m = 1
u = 0.5
c = zeros(101,5)
t = [30,60,90,120,150];
for k = 1:5
c(:,k) = m/sqrt(4*pi*Ex*t(k))*exp(-(x-u*t(k)).^2)./(4*Ex*t(k))
end