Originally posted by: blustori
I've tried that but it generates an error.
Originally posted by: blustori
x being a vector
a = size(x);
temp = 0;
for i=1:a
temp(i) = x(i) * y(i); <---(I'm trying to update the sum each time.)
end
Originally posted by: Atomicus
what does y plus equal b exactly mean?
Originally posted by: clickynext
Originally posted by: Atomicus
what does y plus equal b exactly mean?
b = y + b
QFTOriginally posted by: dighn
Originally posted by: clickynext
Originally posted by: Atomicus
what does y plus equal b exactly mean?
b = y + b
err y += b is y = y + b
Originally posted by: dighn
Originally posted by: blustori
x being a vector
a = size(x);
temp = 0;
for i=1:a
temp(i) = x(i) * y(i); <---(I'm trying to update the sum each time.)
end
isn't "temp" a scalar? but you used temp(i)
Originally posted by: blustori
x being a vector
a = size(x);
temp = 0;
for i=1:a
temp(i) = x(i) * y(i); <---(I'm trying to update the sum each time.)
end
Originally posted by: fawhfe
Originally posted by: dighn
Originally posted by: blustori
x being a vector
a = size(x);
temp = 0;
for i=1:a
temp(i) = x(i) * y(i); <---(I'm trying to update the sum each time.)
end
isn't "temp" a scalar? but you used temp(i)
Yeah easy solution is to initialize temp as a vector (presumably you want one of size a with elements to 0) instead of a scalar by doing
temp=zeros(a);
Originally posted by: fawhfe
Originally posted by: dighn
Originally posted by: blustori
x being a vector
a = size(x);
temp = 0;
for i=1:a
temp(i) = x(i) * y(i); <---(I'm trying to update the sum each time.)
end
isn't "temp" a scalar? but you used temp(i)
Yeah easy solution is to initialize temp as a vector (presumably you want one of size a with elements to 0) instead of a scalar by doing
temp=zeros(a);
Originally posted by: nissan720
each of the variables (aka: vectors, scalars, whatever < technical term) need to be defined(at the start of the progam). You should also do this in a .mat file so it will run it as a program.
Such as:
y = 0
b = 0
while y <= 2000
y = y^2 + y
b = b+1
end
Originally posted by: blustori
x being a vector
a = size(x);
temp = 0;
for i=1:a
temp(i) = x(i) * y(i); <---(I'm trying to update the sum each time.)
end
Originally posted by: blustori
I'm trying to get the dot product of two vectors explicitly so I'm using that for-loop. Anyways, I want a scalar answer and I kind of see where I am going wrong. Can't set vectors = scalars x__x. helps!
Originally posted by: dighn
Originally posted by: blustori
I'm trying to get the dot product of two vectors explicitly so I'm using that for-loop. Anyways, I want a scalar answer and I kind of see where I am going wrong. Can't set vectors = scalars x__x. helps!
change
temp(i) = x(i) * y(i);
to
temp = temp + x(i) * y(i);
Originally posted by: blustori
any way to print that out to the screen? even better, set it equal to my funtion name lets say:
ans = temp;
end
