MATLAB Answers

0

Error when trying to modify a code (vectors)

Asked by Jenny Andersen on 16 Nov 2019 at 14:02
Latest activity Edited by Jenny Andersen on 17 Nov 2019 at 19:25
sgh

  0 Comments

Sign in to comment.

3 Answers

Answer by Image Analyst
on 16 Nov 2019 at 16:08
 Accepted Answer

Try this:
disp(' ')
disp('This program computes the vectors v that are:');
disp(' - ortogonal to w')
disp(' - have length 1')
disp(' - have zero as the first component')
disp(' ')
str = input('Please enter a vector w=[w1 w2 w3]: ', 's');
w = sscanf(str, '%f %f %f')
disp(' ');
v1=1*w;
v2=2*w;
v3=3*w;
v4=4*w;

  0 Comments

Sign in to comment.


Answer by Jenny Andersen on 16 Nov 2019 at 16:26

Thanx, but does this mean I can just insert the expressions for v ( v1 = +/- w2/((w3^2)+(w2^2)) and v2 = +/- w3/((w3^2)+(w2^2)) )?
Sorry I am very new at this

  0 Comments

Sign in to comment.


Answer by Steven Lord
on 16 Nov 2019 at 16:47

You can directly use the elements of a vector through indexing. You don't need to extract them into separate variables.
w = [1 4 9] % Sample
v = w(3) - w(2).^2 + w(1) % 9 - 4*4 + 1 = -6

  0 Comments

Sign in to comment.