ni(i,1:2) is supposed to be a 2x2 vector but i keep getting a 1x2, help please
x = [0 0; 200 0; 200 25; 25 25; 25 200; 0 200;0 0];
n = size(x,1); % size will be equal to 7
n = n-1;
% initialize properties
Asum = 0 ; % a scalar
psum = zeros(1,2); % 1 x 2 matrix
R = zeros(2,2); % 2 x 2 matrix
% 3. loop over sides
for i = 1:n % 5 points
h(i) = norm(x(i,:));
% from 3a as well
ni(i,1:2) = x(i,:)'; %------------------------------------
b(i) =norm(x(i+1,:)-(x(i,:)));
mi(i,1:2) = (x(i+1,:)-x(i,:))';
if h>0
ni = ni/h(i);
end
if b(i)>0
mi(i,1:2) = mi(i,1:2)/b(i);
end

댓글 수: 5

Walter Roberson
Walter Roberson 2019년 8월 4일
In order for ni(i, 1:2) to be 2x2 then i would need to be a vector of length 2. But you are in a for i loop so i is a scalar.
alexis cordova
alexis cordova 2019년 8월 4일
so how will i go about making that a matrix while storing it as well
Walter Roberson
Walter Roberson 2019년 8월 4일
편집: Walter Roberson 2019년 8월 4일
Do you want ni(i,1:2) to end up being two copies of x(i,:)' with both columns the same? If not then which two rows should be used, and should you be using two rows for norm(x(i,:));
alexis cordova
alexis cordova 2019년 8월 4일
so when the loop is ran once im trying to get this below for mi and ni and aslo store it
Capture.PNG
but instead im getting
Capture.PNG
mi(i,1:2) = (x(i+1,:)-x(i,:))';
The left hand side is one row and two columns. Perhaps you want
mi(1:2, i) = (x(i+1,:)-x(i,:)).';

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Special Functions에 대해 자세히 알아보기

제품

릴리스

R2018b

태그

질문:

2019년 8월 4일

댓글:

2019년 8월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by