How can I change the dimension of a global variable?
이전 댓글 표시
I want to define a global variable:
global v
v=[1 2]
but I have this error: Size mismatch (size [1 x 1] ~= size [2 x 1]). The size to the left is the size of the left-hand side of the assignment. How can I change the dimension of v? In the data store memory?
댓글 수: 7
James Tursa
2014년 6월 23일
Is this in Simulink?
alessandro
2014년 6월 23일
alessandro
2014년 6월 23일
José-Luis
2014년 6월 23일
Alessandro, if you want better answers, I would suggest you provide better feedback to the people that are trying to help you, instead of basically asking the same question again.
alessandro
2014년 6월 23일
Also, you would make it easier for people to help you if you:
- Provide more details
- Give a minimum working example reproducing the problem you face. Often, by doing that, you will find the answer yourself.
- Provide feedback to the people that try to help you.
What is the data store memory? Have you tried the debugger?
alessandro
2014년 6월 23일
편집: alessandro
2014년 6월 23일
답변 (1개)
Star Strider
2014년 6월 23일
I cannot reproduce the error in R2014a. It works even if I assign v before I declare it as a global. However this:
v = pi
global v
v = [1 2]
throws this warning:
Warning: The value of local variables may have been changed to match the globals. Future versions of MATLAB will
require that you declare a variable to be global before you use that variable.
What version are you using?
댓글 수: 1
alessandro
2014년 6월 23일
편집: alessandro
2014년 6월 23일
카테고리
도움말 센터 및 File Exchange에서 Image Preview and Device Configuration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

