I have two cells(a and b) each with size 1x4 and each of them contains 2x1 matrix in each of its columns. I would like to find diag([a b]) to get a 2x2 matrix but it seems that diag() is not defined for cell. Can anybody tell me what I should do?
What 2x2 matrix are you looking for? diag([a b]) would provide a 2x1 matrix. Are you looking for [diag(a) diag(b)]? When asking questions, please provide sample inputs with an example of the expected result.
Note that that returns 8 2x2 matrix cells. The OP only mentioned a result of a 2x1 matrix (perhaps it was meant to be 8 of these?) Gotta love clear requests.
Your question asked for a 2x1 matrix. Please explain what you are looking for. Provide me example values for "a" and "b", and what you expect your result from "diag" to be. I wish I could read your mind.
Oh sorry, I meant 2x2 not 2x1. I edited the question. when I type a in the command window to see its value, it only gives me the size of each of its 4 columns but how can I see the value in each column?
What is b supposed to be? What is the final solution to this problem supposed to be? You are leaving out important information. If I gave you a = {[1;2] [3;4] [5;6] [7;8]}; and b = {[.1;.2] [.3;.4] [.5;.6] [.7;.8]}; What would the result of your diag([a b]) be?
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.