当我对值进行硬编码时,我希望将JSON值传递给外部函数,所有这些都按预期工作。当我尝试将值存储在变量中(并将单引号连接到开头和结尾)时,程序挂起并且无法继续(未提供错误消息)。
硬编码数据:
data = '[{"frameData":[232,213,207,223,208,226,222,214,218,241,229,216,228,223,218,214,252,271,255,267,280,257,216,212,213,213,219,226,230,233,200,205,218,220,204,227,206,231,223,216,221,236,238,203,224,220,229,223,257,244,241,239,235,232,223,216,222,205,219,233,225,222,222,227,221,219,211,218,215,231,224,218,216,223,230,228,216,229,233,212,246,227,232,226,223,224,229,202,212,220,228,242,223,237,216,210,223,221,224,219,203,227,229,215,216,240,239,221,223,222,216,209,255,211,230,246,235,226,222,218,211,212,221,230,222,233,220,207,214,221,212,235,209,225,229,214,214,238,239,222,231,229,226,215,239,221,229,223,235,229,240,226,212,216,218,219,225,229,207,199,218,214,224,221,215,224,223,211,216,228,235,214,230,225,229,216,234,222,224,216,232,224,229,217,216,218,217,229,227,233,218,205,220,212,230,223,222,222,230,215,214,222,233,228,230,221,220,218,227,223,218,222,220,223,226,214,220,216,220,235,229,227,213,211,223,227,229,229,227,220,220,216,221,233,227,208,229,224,226,222,231,222,220,226,222,231,235,224,230,219,218,219,218,230,218,220,233,236,227,233,208,222,223,209,219,224,233,218,229,233,230,216,235,214,218,222,230,232,225,214,220,216,218,244,227,226,210,222,227,225,226,230,212,225,227,211,218,235,227,222,229,226,237,222,235,218,220,224,223,233,233,223,220,216,224,223,227,226,212,211,233,220,220,225,227,231,228,216,220,230,221,219,222,225,231,215,233,218,222,225,234,228,224,222,222,216,221,238,220,214,222,216,223,218,214,227,214,226,225,214,213,233,233,223,232,227,223,216,233,223,257,226,236,238,237,214,222,223,225,231,225,226,211,218,231,222,226,232,213,229,229,218,214,234,232,211,235,231,224,226,241,230,316,227,238,230,229,225,231,224,221,230,224,239,222,218,232,222,229,224,214,231,231,227,219,236,236,220,233,226,228,219,232,231,227,229,229,236,231,217,226,223,226,238,224,214,220,220,214,211,233,227,220,227,224,223,226,236,228,221,233,228,235,219,241,225,270,254,228,240,239,209,225,213,215,238,229,227,210,222,233,218,216,219,214,228,233,226,218,236,235,222,227,230,224,226,230,246,283,246,249,259,243,226,223,227,217,234,232,236,214,216,230,220,217,222,198,220,226,214,218,238,232,222,233,230,236,213,261,286,247,256,243,257,265,233,224,218,224,243,231,239,215,219,240,222,230,224,223,227,222,205,227,228,234,226,233,229,234,223,295,255,246,263,260,246,290,236,223,216,226,241,231,220,222,218,223,222,227,218,219,232,216,220,218,234,233,226,229,229,230,216,264,277,281,280,280,283,293,239,224,219,224,227,233,243,229,229,223,217,224,233,212,216,234,220,213,233,229,233,231,236,234,214,235,267,281,278,280,317,293,262,220,216,227,235,223,233,221,229,230,222,226,226,216,229,228,218,212,231,230,219,232,227,235,218,233,221,277,293,276,278,281,265,242,216,220,231,233,236,213,224,222,221,235,226,223,232,222,220,208,234,232,219,222,220,226,221,240,224,238,259,281,284,283,268,226,212,223,230,221,235,229,222,235,213,222,214,227,222,225,226,229,235,236,218,233,236,233,225,235,222,215,229,232,246,247,230,227,222,233,240,221,226,224,210,228,223,222,216,219,227,235,221,216,239,239,233,239,238,235,238,235,222,221,230,235,241,241,220,232,232,218,231,212,229,216,220,222,220,228,225,218,235,232,226,223,241,243,228,238,241,241,236,242,226,214,223,241,241,240,213,229,219,229,236,225,223,223,224,232,210,229,214,216,233,233,226,221,241,232,216,236,235,235,227,242,221,222,230,238,237,238,231,227,229,224,230,216,230,215,217,226,212,222,227,214,235,221,215,224,229,229,225,233,235,227,224,232,229,216,218,241,241,236,229,224,216,228,222,222,224,220,222,226,214,230,217,211,230,227,220,230,236,240,225,236,234,240,220,245,229,222,221,231,229,247,230,223,223,227,224,218,230,225,232,218,214,225,223,222,226,225,220,221,236,233,222,232,229,233,227,240,217,227,222,229,236,232,213,221,216,216,219,229,236,209,235,213,220,228,239,209,235,225,222,222,241,238,220,239,236,232,220,230,222,219,223,218,224,234,209,233,233,226,246,228,236,209,233,221,211,227,224,204,227,238,221,216,254,240,227,239,269,238,221,236,229,235,227,227,243,239,245,257,260,227,235,227,229,193,197,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"height":32,"sensorID":"t0097ff0009b0","width":32}]';
我试图将数据存储在变量中并添加单引号(外部函数需要一个字符串)
JSONdataURL ='http://193.61.148.129:80/thermalDataTea130818.json';
newData = urlread(JSONdataURL);
dataItem = extractBetween(newData, '[{','}]','Boundaries','inclusive');
test = strcat("'", dataItem(1), "'")
更新:
newData输出:
'[{"frameData":[232,213,207,223,208,226,222,214,218,241,229,216,228,223,218,214,252,271,255,267,280,257,216,212,213,213,219,226,230,233,200,205,218,220,204,227,206,231,223,216,221,236,238,203,224,220,229,223,257,244,241,239,235,232,223,216,222,205,219,233,225,222,222,227,221,219,211,218,215,231,224,218,216,223,230,228,216,229,233,212,246,227,232,226,223,224,229,202,212,220,228,242,223,237,216,210,223,221,224,219,203,227,229,215,216,240,239,221,223,222,216,209,255,211,230,246,235,226,222,218,211,212,221,230,222,233,220,207,214,221,212,235,209,225,229,214,214,238,239,222,231,229,226,215,239,221,229,223,235,229,240,226,212,216,218,219,225,229,207,199,218,214,224,221,215,224,223,211,216,228,235,214,230,225,229,216,234,222,224,216,232,224,229,217,216,218,217,229,227,233,218,205,220,212,230,223,222,222,230,215,214,222,233,228,230,221,220,218,227,223,218,222,220,223,226,214,220,216,220,235,229,227,213,211,223,227,229,229,227,220,220,216,221,233,227,208,229,224,226,222,231,222,220,226,222,231,235,224,230,219,218,219,218,230,218,220,233,236,227,233,208,222,223,209,219,224,233,218,229,233,230,216,235,214,218,222,230,232,225,214,220,216,218,244,227,226,210,222,227,225,226,230,212,225,227,211,218,235,227,222,229,226,237,222,235,218,220,224,223,233,233,223,220,216,224,223,227,226,212,211,233,220,220,225,227,231,228,216,220,230,221,219,222,225,231,215,233,218,222,225,234,228,224,222,222,216,221,238,220,214,222,216,223,218,214,227,214,226,225,214,213,233,233,223,232,227,223,216,233,223,257,226,236,238,237,214,222,223,225,231,225,226,211,218,231,222,226,232,213,229,229,218,214,234,232,211,235,231,224,226,241,230,316,227,238,230,229,225,231,224,221,230,224,239,222,218,232,222,229,224,214,231,231,227,219,236,236,220,233,226,228,219,232,231,227,229,229,236,231,217,226,223,226,238,224,214,220,220,214,211,233,227,220,227,224,223,226,236,228,221,233,228,235,219,241,225,270,254,228,240,239,209,225,213,215,238,229,227,210,222,233,218,216,219,214,228,233,226,218,236,235,222,227,230,224,226,230,246,283,246,249,259,243,226,223,227,217,234,232,236,214,216,230,220,217,222,198,220,226,214,218,238,232,222,233,230,236,213,261,286,247,256,243,257,265,233,224,218,224,243,231,239,215,219,240,222,230,224,223,227,222,205,227,228,234,226,233,229,234,223,295,255,246,263,260,246,290,236,223,216,226,241,231,220,222,218,223,222,227,218,219,232,216,220,218,234,233,226,229,229,230,216,264,277,281,280,280,283,293,239,224,219,224,227,233,243,229,229,223,217,224,233,212,216,234,220,213,233,229,233,231,236,234,214,235,267,281,278,280,317,293,262,220,216,227,235,223,233,221,229,230,222,226,226,216,229,228,218,212,231,230,219,232,227,235,218,233,221,277,293,276,278,281,265,242,216,220,231,233,236,213,224,222,221,235,226,223,232,222,220,208,234,232,219,222,220,226,221,240,224,238,259,281,284,283,268,226,212,223,230,221,235,229,222,235,213,222,214,227,222,225,226,229,235,236,218,233,236,233,225,235,222,215,229,232,246,247,230,227,222,233,240,221,226,224,210,228,223,222,216,219,227,235,221,216,239,239,233,239,238,235,238,235,222,221,230,235,241,241,220,232,232,218,231,212,229,216,220,222,220,228,225,218,235,232,226,223,241,243,228,238,241,241,236,242,226,214,223,241,241,240,213,229,219,229,236,225,223,223,224,232,210,229,214,216,233,233,226,221,241,232,216,236,235,235,227,242,221,222,230,238,237,238,231,227,229,224,230,216,230,215,217,226,212,222,227,214,235,221,215,224,229,229,225,233,235,227,224,232,229,216,218,241,241,236,229,224,216,228,222,222,224,220,222,226,214,230,217,211,230,227,220,230,236,240,225,236,234,240,220,245,229,222,221,231,229,247,230,223,223,227,224,218,230,225,232,218,214,225,223,222,226,225,220,221,236,233,222,232,229,233,227,240,217,227,222,229,236,232,213,221,216,216,219,229,236,209,235,213,220,228,239,209,235,225,222,222,241,238,220,239,236,232,220,230,222,219,223,218,224,234,209,233,233,226,246,228,236,209,233,221,211,227,224,204,227,238,221,216,254,240,227,239,269,238,221,236,229,235,227,227,243,239,245,257,260,227,235,227,229,193,197,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"height":32,"sensorID":"t0097ff0009b0","width":32}]
...
[{"frameData":[203,216,224,227,219,201,231,221,219,228,219,230,216,230,225,227,256,283,285,276,223,275,232,199,210,212,224,212,212,229,216,202,206,219,215,219,220,203,223,233,224,231,225,222,213,220,222,241,257,260,263,256,223,245,231,211,220,215,225,211,222,217,219,227,212,218,210,225,229,193,228,226,209,218,222,220,218,212,219,234,259,229,238,234,219,228,221,203,217,221,222,227,217,223,224,219,213,219,209,230,226,222,232,213,207,212,225,221,215,219,233,232,254,226,238,229,215,226,260,222,224,220,231,266,253,213,218,219,213,201,227,224,215,196,222,224,204,217,220,222,222,216,218,239,236,223,232,221,220,224,250,247,237,241,270,274,272,226,221,217,221,210,219,230,228,209,221,225,217,221,221,222,228,221,229,231,237,235,228,225,221,229,219,251,235,248,286,269,261,245,211,213,221,215,219,228,223,206,223,217,213,225,212,220,214,226,219,230,232,231,226,219,215,219,226,267,255,277,299,294,274,259,219,223,213,222,220,222,221,210,228,233,219,221,227,217,225,222,229,226,231,224,232,221,223,239,241,265,274,269,276,293,263,226,224,223,217,214,213,221,222,217,218,222,209,210,213,222,225,223,225,240,228,221,231,230,229,233,266,249,242,264,248,256,216,215,223,212,231,219,223,235,242,208,218,217,215,216,226,225,222,219,225,242,236,231,232,214,225,237,239,238,247,233,232,228,207,221,218,213,224,223,222,225,223,204,229,222,217,208,218,226,228,221,228,240,241,228,226,232,226,235,229,220,227,213,227,221,221,221,220,212,221,222,223,225,221,211,225,226,216,225,228,221,213,219,225,237,234,232,271,225,226,232,231,220,231,217,223,227,221,224,219,215,232,228,214,232,228,220,221,226,222,217,217,228,223,225,236,237,234,245,318,231,228,237,234,223,228,213,226,221,216,221,215,213,235,219,222,221,230,206,225,229,209,226,223,231,225,222,231,225,233,231,237,228,233,242,222,225,226,213,222,224,210,221,229,211,229,223,221,232,228,212,222,222,217,213,217,226,234,225,229,232,233,234,232,232,229,242,229,212,222,209,230,228,217,215,225,217,230,224,221,226,229,219,224,225,222,220,224,219,233,220,232,244,235,224,236,227,233,232,226,222,228,221,223,225,227,229,226,226,223,225,225,229,221,201,229,224,208,221,222,228,232,228,230,238,227,231,235,223,226,240,233,211,225,216,225,234,216,236,228,226,218,225,215,228,226,208,223,228,215,221,218,219,225,227,220,239,244,229,232,221,219,238,235,226,234,209,229,226,222,232,239,242,221,227,206,234,224,214,221,229,210,218,219,225,225,228,232,242,236,234,231,217,229,221,225,217,221,215,231,225,221,220,228,224,226,219,207,234,226,204,222,225,222,220,228,234,222,214,233,240,230,216,231,228,217,227,226,225,219,215,221,228,214,232,223,221,222,216,210,224,226,217,235,216,216,213,222,216,232,220,225,235,230,219,229,223,222,229,232,223,226,218,223,230,234,223,229,223,231,212,212,226,225,203,229,230,219,215,221,224,225,229,221,233,229,224,225,219,217,234,226,212,222,221,226,225,228,240,235,222,215,215,219,224,222,208,230,225,232,219,235,221,221,229,235,250,223,217,229,219,225,219,230,221,232,227,228,219,206,221,222,220,220,216,220,223,228,208,226,241,213,223,231,235,234,223,232,245,235,229,232,215,240,239,233,225,237,204,230,234,205,220,219,211,213,217,219,234,219,214,220,225,222,225,219,240,231,231,230,241,235,231,227,226,230,239,234,222,225,228,234,234,216,222,228,225,212,229,222,228,223,222,232,232,212,220,226,221,226,230,226,242,238,229,223,223,236,234,240,223,217,225,231,234,222,221,222,219,230,212,221,235,234,210,225,226,226,218,225,225,227,229,232,240,252,235,238,212,229,238,239,223,229,218,243,231,221,217,232,227,223,219,216,237,227,200,231,232,229,220,226,226,228,226,230,232,235,235,225,216,227,241,231,227,224,217,222,226,215,222,235,235,242,220,225,229,220,207,224,235,217,216,216,212,231,226,241,235,245,235,227,221,225,228,231,215,217,211,224,216,219,213,215,229,219,212,221,219,220,214,228,229,214,217,226,229,225,238,238,231,228,223,229,215,225,233,233,217,222,216,222,216,219,214,221,213,212,213,204,233,228,193,221,213,219,253,237,226,221,257,242,237,233,242,224,219,229,237,234,229,262,271,219,223,206,217,230,215,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"height":32,"sensorID":"t0097ff0009b0","width":32}]
'