필터 지우기
필터 지우기

how can I concatenate [aa,bb]?

조회 수: 2 (최근 30일)
Abhinandan Angadi
Abhinandan Angadi 2021년 5월 31일
댓글: Mathieu NOE 2021년 5월 31일
clear all
close all
clc
x = linspace(1,50,25);
a = 100;
for n = 1:25
aa(1,1) = x(n).*9.81.*(a\x(n)).^2
if aa <= 50
disp('its valid')
elseif aa >= 51 && aa <= 75
disp('its valid but bigger')
else
disp('out of control')
end
end
y = linspace(1,100,25);
b = 200;
for m = 1:25
bb(1,1) = y(m).*9.81.*(a\y(m)).^2
if bb <= 50
disp('its valid')
elseif bb >= 51 && bb <= 75
disp('its valid but bigger')
else
disp('out of control')
end
end
for d = 1:25;
A(d) = [aa,bb]
end

채택된 답변

Mathieu NOE
Mathieu NOE 2021년 5월 31일
hello
I believe there are a frew mistakes as aa and bb are not indexed in the for loops , so you have a scalar that will be overwritten at each for loop iteration
therefore I modified your code this way :
clear all
close all
clc
x = linspace(1,50,25);
a = 100;
for n = 1:25
% aa(1,1) = x(n).*9.81.*(a\x(n)).^2
aa(n) = x(n).*9.81.*(a\x(n)).^2;
if aa(n) <= 50
disp('its valid')
elseif aa(n) >= 51 && aa(n) <= 75
disp('its valid but bigger')
else
disp('out of control')
end
end
y = linspace(1,100,25);
b = 200;
for m = 1:25
% bb(1,1) = y(m).*9.81.*(a\y(m)).^2
bb(m) = y(m).*9.81.*(a\y(m)).^2;
if bb(m) <= 50
disp('its valid')
elseif bb(m) >= 51 && bb(m) <= 75
disp('its valid but bigger')
else
disp('out of control')
end
end
A = [aa' bb'];
  댓글 수: 2
Abhinandan Angadi
Abhinandan Angadi 2021년 5월 31일
thanks for rectifying.
Mathieu NOE
Mathieu NOE 2021년 5월 31일
you're welcome

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by