Putting array indexes into a larger one
1 回表示 (過去 30 日間)
古いコメントを表示
I have 200x1 bitcells, every cell element is made by 3x1 char strings, represents 3 bits like '101' . I am reading this cells as integers, then I attain -1 or 1 value. The problem is when I try to put this -1 and 1s into 600x1 volts array, it puts wrong values, some elements are missed so stays 0. I checked the singlevolts array always true in every iteration but I couldn't put that values in 600x1 array correctly. Any help will appreciated, thank you community. Stay safe!
for m=1:1:200
for n=1:1:3
if (str2num(bitcells{m}(n)) == 0)
singlevolts(n) = -1
else singlevolts(n) = 1
end
end
volts(m*1) = singlevolts(1)
volts(m*2) = singlevolts(2)
volts(m*3) = singlevolts(3)
end
0 件のコメント
採用された回答
Deepak Gupta
2020 年 5 月 6 日
編集済み: Deepak Gupta
2020 年 5 月 6 日
Hello Mert,
I am not completely sure what you want to do but got some impression so have made some modification in your code.
for m=1:1:200
for n=1:1:3
if (str2num(bitcells{m}(n)) == 0)
singlevolts(n) = -1
else singlevolts(n) = 1
end
end
volts(3*(m-1)+1) = singlevolts(1);
volts(3*(m-1)+2) = singlevolts(2);
volts(3*(m-1)+3) = singlevolts(3);
end
If this doesn't solve your problem, then attach your cell array, with required end result.
Cheers.
1 件のコメント
Deepak Gupta
2020 年 5 月 6 日
編集済み: Deepak Gupta
2020 年 5 月 6 日
for m=1:200
for n=1:3
if (str2num(bitcells{m}(n)) == 0)
singlevolts= -1
else singlevolts= 1
end
volts(3*(m-1)+n) = singlevolts;
end
end
It can do the same thing.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!