mxArray to double?

조회 수: 34 (최근 30일)
Ho Jung Kim
Ho Jung Kim 2022년 7월 28일
댓글: Abderrahim. B 2022년 8월 1일
I am using simevents and using importdata to bring variable from .mat file to simevents. I want to use this variable in if statement and possibly change the value as well. However, I am getting this error:
Expected either a logical, char, int, fi, single, or double. Found an mxArray. MxArrays are returned from calls to the MATLAB interpreter and are not supported inside expressions. They may only be used on the right-hand side of assignments and as arguments to extrinsic functions.
Is there a way to fix this? mxArray to double? I have an example below
choice.mat has one variable.
I have tried declaring the variable count as doule and called importdata, but I'm still getting the same error.
  댓글 수: 2
James Tursa
James Tursa 2022년 7월 28일
Please show us the relavant code.
Ho Jung Kim
Ho Jung Kim 2022년 7월 28일
I added an example. Thank you.

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

답변 (1개)

Abderrahim. B
Abderrahim. B 2022년 7월 29일
Hi!
I' m not sure how did define variable count as double!
Try to preinitialize the variable count before calling the function.
count = zeros(size(count))
If you don't know the size of your variable then use zeros .
Hope this helps
  댓글 수: 2
Ho Jung Kim
Ho Jung Kim 2022년 8월 1일
Thank you so much! This works!!!
Abderrahim. B
Abderrahim. B 2022년 8월 1일
Glad it worked.
- If you found my answer helpful and want others with same issue to refer to it, accept it!

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

카테고리

Help CenterFile Exchange에서 Discrete-Event Simulation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by