How to distribute runtime input values to two vectors?

조회 수: 9 (최근 30일)
Ali
Ali 2024년 10월 31일
답변: 埃博拉酱 2024년 11월 1일
Hello to everyone.
So I have to make a and b vectors from user input vector, so that a concludes even numbers of input and b the odd ones. My idea is to calculate rem of each number of arrey and then contribute them. However I don't know how exactly tell Matlab to do that. I got so far but I can't find a way to make vectors from multiple outputs and it only returns the last one value.

답변 (2개)

Walter Roberson
Walter Roberson 2024년 10월 31일
You would use something like
a = [a, i(n)];
... making sure that you had initialized a before the loop.

埃博拉酱
埃博拉酱 2024년 11월 1일
function [a,b]=DistributeEvenOdd
F = str2num(string(inputdlg('Enter a Vector','Vector',[1 50])));
while(numel(F) ~= 6)
F = str2num(string(inputdlg('Enter a 1*6 Vector','Vector',[1 50])));
end
Logical=logical(bitget(F,1));
a=F(~Logical);
b=F(Logical);
end

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by