how can I concatenate [aa,bb]?

2 次查看(过去 30 天)
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'];

更多回答(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