필터 지우기
필터 지우기

Problems converting to C/C++

조회 수: 2 (최근 30일)
George Lazaridis
George Lazaridis 2014년 7월 19일
답변: Andy Sonnenburg 2014년 7월 25일
I am converting some of my code to C/C++ and I am getting as expected a lot of error. For example the following piece of code returns error while building due to the fact that i am using a cell, something that is not supported by the compiler. What can i do? Thank you in advance for your time and consideration
K = logical(diff([x(1)+abs(x(1))*2e-7; x; x(end)-abs(x(end))*2e-7])<=0); %
L = {K(2:end) & [K(2); K(2:end-1)~=K(3:end)]};
L = cell2mat(L(1));

답변 (1개)

Andy Sonnenburg
Andy Sonnenburg 2014년 7월 25일
In this particular case, the cell array use is not absolutely necessary. Try
K = logical(diff([x(1)+abs(x(1))*2e-7; x; x(end)-abs(x(end))*2e-7])<=0);
L = K(2:end) & [K(2); K(2:end-1)~=K(3:end)];
A cell array can often be replaced with a matrix when all cells of the cell array are of the same type. In this particular case, the cell array has only a single element, and therefore all elements are of the same type.

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by