我目前正在编写一个模块来为我的MATLAB项目编写HTML内容。 为了保持灵活性,我编写了这样的代码:
function content = get_content(obj, elements)
% Return the HTML of the page
body_content = obj.get_body(elements);
header_content = obj.get_header();
content = {
header_content{:} ...
body_content{:} ...
'</html>' ...
};
end
function content = get_header(obj, elements)
content = {
'<!DOCTYPE html>' ...
'<html lang="en">' ...
'<head>' ...
' <meta charset="utf-8" />' ...
' <title>Report</title>' ...
' ' ...
' <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">' ...
' <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>' ...
' <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>' ...
' <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>' ...
' ' ...
obj.css{:} ...
'</head>' ...
}
end
% ....
因此,当我尝试连接其他函数返回的内容时,出现我的问题 目前,我必须这样做:
function content = get_content(obj, elements)
% Return the HTML of the page
body_content = obj.get_body(elements);
header_content = obj.get_header();
content = {
header_content{:} ...
body_content{:} ...
'</html>' ...
};
end
但是,我希望所有内容都在同一行,就像这样:
function content = get_content(obj, elements)
% Return the HTML of the page
content = {
obj.get_header(){:} ...
obj.get_body(elements){:} ...
'</html>' ...
};
end
很明显,当我这样做时,出现以下错误:
()-indexing must appear last in an index expression.
您是否有一种简单的方法/技巧来做这样的事情?
致谢