Hi, when I run "enzymleastsquares.m" I get an odd error
"Invalid use of operator"
I used originally the normal =, but MATLAB asked me to change this to == , then I got this error as stated.
type('enzymeLeastSquares.m')
function [result,grad_all] = enzymeLeastSquares(k) N = 4; % number of experiments result = zeros(2*N,1); % pre-allocate result arrays grad_all = zeros(2*N,2); dt=0.01; T=1; %k=[5;1]; y0_all = [2 1 1 4; 1 1 0 1]; y1_all = [1.0 0.5 0.3 2.4; 2.1 1.6 0.9 2.7]; for ii = 1:N y0 = y0_all(:,ii); y1 = y1_all(:,ii); [SP,grad]=enzyme(y0,k,dt,T); result((ii-1)*2+[1 2]) = y1-SP; grad_all((ii-1)*2+[1 2], == -grad; end
Where is the error here? All seems fine in the grad_all operator!
Thanks

댓글 수: 2

Dyuman Joshi
Dyuman Joshi 2024년 3월 26일
편집: Dyuman Joshi 2024년 3월 26일
How are you calling the function enzymeLeastSquares.m?
What is this line supposed to do?
grad_all((ii-1)*2+[1 2], == -grad;
2nd last line in the same function.
Also, copy and paste your full error message i.e. all of the red text. Whenever you encounter an error, best to provide the full details of it.
Steven Lord
Steven Lord 2024년 3월 26일
Note that if you edit enzymeLeastSquares.m in the MATLAB editor, you receive two Code Analyzer messages.
One is orange, indicating that the variable grad defined on line 13 is not used. [I know you use it on line 15, but keep reading.]
The second, more serious message, is red indicating a fatal error that will prevent your code from running to completion. That's on line 15, which @Dyuman Joshi already called out in their comment. MATLAB doesn't understand what you're trying to do there. It's not valid MATLAB syntax.

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

 채택된 답변

Voss
Voss 2024년 3월 26일
이동: Voss 2024년 3월 26일

0 개 추천

Looks like you mean to say:
grad_all((ii-1)*2+[1 2],:) = -grad;

추가 답변 (0개)

카테고리

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

제품

릴리스

R2024a

질문:

2024년 3월 26일

댓글:

2024년 3월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by