Azzera filtri
Azzera filtri

Matlab cell array question

3 visualizzazioni (ultimi 30 giorni)
Lam Chun Ting
Lam Chun Ting il 31 Mar 2012
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!!

Risposte (2)

Wayne King
Wayne King il 31 Mar 2012
  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 Commento
Lam Chun Ting
Lam Chun Ting il 31 Mar 2012
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?

Accedi per commentare.


Wayne King
Wayne King il 31 Mar 2012
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 Commento
Lam Chun Ting
Lam Chun Ting il 31 Mar 2012
thx for your help..I will have a look by myself

Accedi per commentare.

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Community Treasure Hunt

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

Start Hunting!

Translated by