how can I concatenate [aa,bb]?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Abhinandan Angadi
am 31 Mai 2021
Kommentiert: Mathieu NOE
am 31 Mai 2021
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
0 Kommentare
Akzeptierte Antwort
Mathieu NOE
am 31 Mai 2021
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Google finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!