필터 지우기
필터 지우기

GUIDE

조회 수: 2 (최근 30일)
john
john 2012년 3월 6일
Hi, I have problem with this:
martixA=zeros(4,4)
UserData.matrixA(1,1)=sym(strcat('-',(get(handles.edit5,'string'))));.....................
if string is number like 4.884032 it is ok, but in case if string is like "alfa", it is error,,,,,why???
Please, can you help me??

채택된 답변

Kevin Holst
Kevin Holst 2012년 3월 6일
You can't put a 5 character string into a single spot in a matrix. You'll need to use cell arrays to do what you're trying to do.
  댓글 수: 3
Kevin Holst
Kevin Holst 2012년 3월 6일
Well it all depends. If you're only going to want matrixA to contain numbers, I'd keep it as a double matrix and error check the string you get to make sure the user input a number. If you need to keep whatever they input, character string or numeric, in matrixA, then matrixA will need to be a cell array. If you need it to be a cell array, this is the syntax (assuming you haven't put anything into matrixA earlier in the code):
UserData.matrixA{1,1}=sym(strcat('-',(get(handles.edit5,'string'))))
john
john 2012년 3월 6일
Thank you man for help to understand it.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by