フィルターのクリア

Please help me fix the count for the nested for-loop

1 回表示 (過去 30 日間)
Irwin2020
Irwin2020 2018 年 11 月 30 日
編集済み: Irwin2020 2018 年 12 月 26 日
function [ result ] = Clockregister01( R,count )
clc
for j = 1:count
for i = 1: size(RN,1)-1
% RN(i,1:size(RN,2)) = addHexNumber(RN(i,1:size(RN,2)),RN(i+1,1:size(RN,2)))
RN(i) = addHexNumber(RN(i),RN(i+1))
end
end
result = RN;
end
  2 件のコメント
madhan ravi
madhan ravi 2018 年 11 月 30 日
編集済み: madhan ravi 2018 年 11 月 30 日
count value?
Irwin2020
Irwin2020 2018 年 11 月 30 日
Yes

サインインしてコメントする。

採用された回答

Mark Sherstan
Mark Sherstan 2018 年 11 月 30 日
I dont fully understand the end goal of your function but your error was coming from redefining Rn as well as some of your indices. The following now runs however I am not sure what values you need to store / reference but hopefully this will push you in the right direction.
function [result] = Clockregister01(R,count)
R = ['000000000000000000000000000000000000000000';
;'000000007FE906A41162B1720C281817AA5644BC80'
;'FFFFFFFFFFFFFFFFE6604FFCF6DA1466C024D53905'
;'0000000000000000023FEF553317DFDBA061CE3DF3'
;'00000000000000000000000523CE74ABBF21076BB8'
;'FFFFFFFFFFFFFFFFFFFFFFFFFFE04F0941AF9FF0D3'];
RN = R;
for j = 1:count
for i = 1:size(RN,1)-1
% RN(i,1:size(RN,2)) = addHexNumber(RN(i,1:size(RN,2)),RN(i+1,1:size(RN,2)))
A = addHexNumber(RN(i,:),RN(i+1,:));
end
end
result = RN;
end
  11 件のコメント
Dennis
Dennis 2018 年 12 月 3 日
Your first array (hex1) is 60 digits long, your second array is 46 digits long (hex2). In your function you use the length of hex1 to iterate over both arrays.
size = length(hex1);
for i = size:-1:1 %The index variable i starts at size, then decreases in steps of 1 until it reaches 1.
h1 =typecast(uint64(hex2dec(hex1(i))), 'int64');
h2 =typecast(uint64(hex2dec(hex2(i))), 'int64');
%...
Irwin2020
Irwin2020 2018 年 12 月 6 日
Any idea on how to iterate over both arrays?

サインインしてコメントする。

その他の回答 (1 件)

Dennis
Dennis 2018 年 12 月 5 日
Your addHexNumber function actually does not work correctly. I think you need to change
if bothSum > 16
to
if bothSum > 15 % or >=16
  1 件のコメント
Irwin2020
Irwin2020 2018 年 12 月 5 日
I believe that too, I have debugged and modified it to > 15 and >=16 still doesn’t work, any other suggestions?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by