Converting cell array to matrix

4 Ansichten (letzte 30 Tage)
Tham Tze Guang
Tham Tze Guang am 8 Jan. 2020
Beantwortet: Geoff Hayes am 8 Jan. 2020
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 Kommentar
Alex Mcaulley
Alex Mcaulley am 8 Jan. 2020
screenshots are useless. Please provide the code as a mat file or copy pasting it hhere

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Geoff Hayes
Geoff Hayes am 8 Jan. 2020
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

Weitere Antworten (0)

Kategorien

Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by