Passing the output of SWITCH statement through a function
조회 수: 15 (최근 30일)
이전 댓글 표시
Hi,
I was wondering if anyone may be able to assist with a problem that seems to be driving me mad. I am designing an app with App Designer and through the help of the good people on here, I nearly have it working, just one problem remains.
In my code for the App I have a switch statement dependant on which media my electromagnetic wave is travelling through called "er". What I wish to do is pass the value calculated for er through to a function where a numerical solution may be approximated.
Initially, I wrote the code as executable function and it worked for the different media from the SWITCH statement, however I have 'bolted' the App onto this code so it has a easy access interface.
Can you pass a value from a SWITCH statement through to a function? I have included the code for my app and also the function below and have shown where the problem lies - "Error using fdtd_time_reversal (line 187) Arrays have incompatible sizes for this operation".
Hoping someone may be able to shed some light on this.
Many thanks,
Andy
댓글 수: 0
채택된 답변
Nathan Bblanc
2024년 2월 18일
As you can see from the error message, the function "fdtd_time_reversal" is run, and encounters an error on line 187:
loss = 1 - ((sig*dt)./(er*e0));
The error message indidicates that the array sizes are not what you expected them to be. maybe er is a vector and supposed to be a scalar? try placing a debugger on this line and running the app, and then investigate each variable (sig,dt,er,e0) to see if they are the size you expected. It is also possible that one of the multiplications should be with .* (mutiplying all terms) instead of * (matrix multiplication).
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!