As a student, a spell checker is benefical as our reports are submitted against academic standard invovling grammer/spelling.
MATLAB: Has anyone from the MathWorks team developed a inline spell checker
MATLABspellcheck
Related Solutions
You could try this:
UPDATE : here is a slightly modified version (also attached)
function wordsChecked = checkWordsSpelling( words ) %
% Based on Mathworks thread:
% http://www.mathworks.com/matlabcentral/answers/91885-is-there-any-way-to-check-spelling-from-within-matlab
% % - Split space-separated words into cell array of words, or wrap
% single word into cell array.
if ischar( words ) if any( words == ' ' ) words = strsplit( words, ' ' ) ; else words = {words} ; end end % - Launch MS Word and create document.
h = actxserver( 'word.application' ) ; h.Document.Add ; % - Build cell array of originals and suggestions.
words = words(:) ; % -> columns cell array.
nWords = numel( words ) ; for wId = 1 : nWords % - Check if spelling correct. Loop back if so.
isCorrect = h.CheckSpelling( words{wId,1} ) ; words{wId,2} = isCorrect ; if isCorrect words{wId,3} = false ; continue ; end % - Build cell array of suggestions.
nSug = h.GetSpellingSuggestions( words{wId,1} ).count; words{wId,3} = nSug > 0 ; if nSug > 0 for sId = 1 : nSug words{wId,4}{sId} = ... h.GetSpellingSuggestions( words{wId,1} ).Item(sId).get( 'name' ) ; end end end % - Quit MS Word.
h.Quit % - Build table (or struct array if you prefer).
%wordsChecked = cell2struct( words, {'original', 'isCorrect', 'hasSuggestion', 'suggestion'}, 2 ) ;
wordsChecked = cell2table( words, 'VariableNames', {'original', 'isCorrect', 'hasSuggestion', 'suggestion'} ) ; end
With that, you can do the following:
>> checked = checkWordsSpelling( 'Helloo' ) checked = original isCorrect hasSuggestion suggestion ________ _________ _____________ _______________________________ 'Helloo' false true 'Hello' 'Halloo' 'Hellos' >> checked = checkWordsSpelling( 'Helloo Wolrd Hello' ) checked = original isCorrect hasSuggestion suggestion ________ _________ _____________ __________ 'Helloo' false true {1x3 cell} 'Wolrd' false true {1x2 cell} 'Hello' true false [] >> checked.suggestion{2} ans = 'World' 'Word' >> checked = checkWordsSpelling( {'Helloo', 'Wolrd'} ) checked = original isCorrect hasSuggestion suggestion ________ _________ _____________ __________ 'Helloo' false true {1x3 cell} 'Wolrd' false true {1x2 cell}
Hope it helps!
You can find information regarding MathWorks support for MISRA-C at the following link:
For inquiries about using MISRA-C and MISRA AC ACG with Simulink, Stateflow, or Embedded Coder, contact MathWorks Technical Support at:
Note that MathWorks has a MISRA-C:2004 checker as part of our Polyspace code verification products:
Polyspace offers a unique and powerful capability that detects run-time errors (such as divide by zero) as specified in MISRA C:2004 Rule 21.1.
For information about MISRA-C provided by the Motor Industry Software Reliability Association, visit:
Best Answer