Error when trying to modify a code (vectors)

조회 수: 2 (최근 30일)
Jenny Andersen
Jenny Andersen 2019년 11월 16일
편집: Jenny Andersen 2019년 11월 17일
sgh

채택된 답변

Image Analyst
Image Analyst 2019년 11월 16일
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;

추가 답변 (2개)

Jenny Andersen
Jenny Andersen 2019년 11월 16일
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

Steven Lord
Steven Lord 2019년 11월 16일
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

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by