필터 지우기
필터 지우기

Matlab cell array question

조회 수: 3 (최근 30일)
Lam Chun Ting
Lam Chun Ting 2012년 3월 31일
Create a 2x2 cell array A with the following elements: 4x4 identity matrix; the string ‘Leicester is the largest city in world’, the complex number (3+i*10)^3; the array of N=20 numbers (of type single) representing the geometric progression with the base 5 and the common ratio 1/2. Replace the element ‘Leicester is the largest city in world' with ‘Leicester is a nice town’. Plot the created cell.
I've done my Matlab code for this question, can anyone help me to check this question, please?
A(1,1)={eye(4)};
A(1,2)={'Leicester is the largest city in the world'};
A(2,1)={(3+10i).^3};
A(2,2)={5:1/2:20};
A{1,2}='Leicester is a nice town';
A{1,2}=true;
cellplot(A);
A;
Many thanks for helping!!

답변 (2개)

Wayne King
Wayne King 2012년 3월 31일
  1. (3+1j*10)*3 is not the same as (3+1j*10)^3, so I'm not sure which one you mean when you wrote "(3+i*10)3" Maybe you just forgot the ^?
  2. 5:1/2:20 is not correct. That is a linearly-spaced vector with increments of 1/2. That is not what your assignment wants. Look at a geometric series.
  3. I'm not sure why you put A{1,2} = true; I don't see anything in the question you posted that asks for that.
  댓글 수: 1
Lam Chun Ting
Lam Chun Ting 2012년 3월 31일
1)sorry..I forgot to type ^, but I fix it now.thx
2)May you tell me how would you compute this please?
3) because they ask me to replace the element.‘Leicester is the largest city in world' with ‘Leicester is a nice town’, so I put A{1,2}=true, will it be correct?

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


Wayne King
Wayne King 2012년 3월 31일
I think you were correct when you replaced the string.
A{1,2}='Leicester is a nice town';
A{1,2} = true is replacing .‘Leicester is the largest city in world' with 1. That is not what you want.
You do not need the .^ because you only have a single complex number.
I do not want to just tell you how to produce the series, because it is your assignment. Look at the formula for a geometric series.
  댓글 수: 1
Lam Chun Ting
Lam Chun Ting 2012년 3월 31일
thx for your help..I will have a look by myself

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

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by