Converting cell array to matrix

조회 수: 3 (최근 30일)
Tham Tze Guang
Tham Tze Guang 2020년 1월 8일
답변: Geoff Hayes 2020년 1월 8일
I am having a problem with my assignment, i am making a morse code decoder and i have already written a function file for that. But when i run my function file with input of cell array it only shows the last value as alphabet. Can i know what is wrong with my function file?
(function file) (inputs) (outputs)
  댓글 수: 1
Alex Mcaulley
Alex Mcaulley 2020년 1월 8일
screenshots are useless. Please provide the code as a mat file or copy pasting it hhere

댓글을 달려면 로그인하십시오.

채택된 답변

Geoff Hayes
Geoff Hayes 2020년 1월 8일
Tham - check your for loop
i = length(code);
for n = 1:i
[~,index] = ismember(code(i), morse)
letter(i) = str_letter(index);
end
You use i on each iteration of the loop. I suspect that you want to use n instead
i = length(code);
for n = 1:i
[~,index] = ismember(code(n), morse)
letter(n) = str_letter(index);
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by