Error when trying to modify a code (vectors)
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Jenny Andersen
el 16 de Nov. de 2019
Editada: Jenny Andersen
el 17 de Nov. de 2019
sgh
0 comentarios
Respuesta aceptada
Image Analyst
el 16 de Nov. de 2019
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 comentarios
Más respuestas (2)
Steven Lord
el 16 de Nov. de 2019
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 comentarios
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!