Live script will not run code that "regular" script will

The following code works fine in SCRIPT, but it will not work in Live Script. I am wondering why?
I am running MATLAB 2016b, on an iMAC running OS X Sierra.
Thanks,
---jon---
----------------------------------------------
% A is a 6x2 numerical array. Col 1 has student IDs in it. Col 2 has
% corresponding test scores.
% Find the second largest score, and the ID of the
% student who received the second highest score.
% Assume no duplicate scores.
A = [11 45;
12 98;
13 71;
14 21;
15 34;
16 92];
[sortedScores, ndxSortedScores] = sort(A(:,2));
secondHighestScore = sortedScores(end-1)
ID_secondHighest = A( ndxSortedScores(end-1), 1)

댓글 수: 5

A is not 6x2. A is 1x12. Perhaps that is part of your problem.
Could you provide the error message? I can run your scripts both in m and mlx files.
John, I'm not sure why you say that A would be 1 x 12 ? The code includes explicit ";" which would make it into a 2D array.
The code works for me as Live Script in R2016b on Mac with El Capitan.
The code works for me as Live Script in R2016b on Mac with Sierra in a Virtual Machine.

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

태그

질문:

Jon
2016년 10월 25일

댓글:

2016년 10월 25일

Community Treasure Hunt

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

Start Hunting!

Translated by