필터 지우기
필터 지우기

How do i turn a character array into a double cell

조회 수: 1 (최근 30일)
Gianni Davies
Gianni Davies 2021년 5월 8일
편집: Walter Roberson 2021년 5월 8일
clc;
clear;
I believe the issue is that I am I used listdlg to get a variable
This variable is saved in a character array
I want to use this character array to help get values for a double matrix (default array)
I dont know how to do that
The important lines are
A = [10,10]
%embedded for statement to get information on each space
for k = 1:1:A(10,2)
list = {'Resident','Education','Office','Toilet','Storage'};
[indx,tf] = listdlg('PromptString',sprintf('On Floor %d what spaces are used ')...
,'SelectionMode','single','ListString',list);
typeofspace = list{indx};
%if statement to get exact details for all spaces (height,co ordinate
%etc....)
if typeofspace == 'Resident'
r=r+1;
A(1,3)=r;
elseif typeofspace == 'Education'
e=e+1;
A(1,4)=e;
else
end
Error message
Matrix dimensions must agree.
Error in CourseWorkMain (line 44)
if typeofspace == 'Resident'

채택된 답변

Jonas
Jonas 2021년 5월 8일
i think your actual problem is the way you check character arrays. for thise you have to use strcmp(chararray1,chararray2) instead of chararray1==chararray2. the second expression checks equality for each character and to do that the arrays have to be same length (your error here i think). checking with == will give you one logical exprrssion for each character. but nornally you want just to know if two arrays are the same as whole or not, using strcmp() will give you one logical result
  댓글 수: 1
Gianni Davies
Gianni Davies 2021년 5월 8일
Cheers this works thanks for spotting this issue for me

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by