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.

类别

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