Azzera filtri
Azzera filtri

how can I concatenate [aa,bb]?

2 visualizzazioni (ultimi 30 giorni)
Abhinandan Angadi
Abhinandan Angadi il 31 Mag 2021
Commentato: Mathieu NOE il 31 Mag 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

Risposta accettata

Mathieu NOE
Mathieu NOE il 31 Mag 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 Commenti
Abhinandan Angadi
Abhinandan Angadi il 31 Mag 2021
thanks for rectifying.
Mathieu NOE
Mathieu NOE il 31 Mag 2021
you're welcome

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by