hi every one , i need help to do this in matlab if it's possibile, thank you

1 view (last 30 days)
A=[ 1 2 3 4 5 6 7 8 9 10 ]
B=[ 10 11 12 13 14 15 16 17 18 19 20]
C=[ 21 22 23 24 25 26 27 28 29 30]
for n=1:10
if n==1 & 6<=n<=9 % if n is uquale to this value i need to make this operation
X=A+B
if n==2 & 3<=n<=5 % if n is uquale to this value i need to make this operation
X=A+B+C
else % else in need to make this
X=B+C
end
end
tnak you
  2 Comments
Stephen23
Stephen23 on 8 Jul 2019
Edited: Stephen23 on 8 Jul 2019
Disregarding the MATLAB syntax bug, when do you expect these logical conditions to be true?:
n==1 & 6<=n<=9
n==2 & 3<=n<=5
Can you give any value of n for which this will be true? Fixing the syntax bug gives:
n==1 & 6<=n & n<=9
n==2 & 3<=n & n<=5
but still no value of n that will ever produce a true output. Did you really mean to use OR ?:
n==1 | (6<=n & n<=9)
n==2 | (3<=n & n<=5)

Sign in to comment.

Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!