Basic Matlab tables containing text [closed] - matlab

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I need to type some matrix containing both letters and numbers.
Something like list=["a" 1;" b" 2; "c" 3; "d" 4; "e" 5; "f" 6; "g" 7]
Can anybody give me some tip?

If you want "just" a mix of strings and numbers, use a cell array. See the MATLAB documentation here.
If you're trying to set up some kind of map/hash, you want a MATLAB "structure." See the documentation for that here.

Related

How the matlab code gives a strange output and How to explain it? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I understand how the program works but I have a little bit of confusion. If anybody can explain, that will be great. The output is 21, 12. Does it work like 7*3=21 and 4*3=12?
mat=[7 11 3; 3:5];
[r,c]=size(mat);
for i=1:r
fprintf ('The sum is %d\n',sum(mat(i,:)))
end
mat(i,:) will give you all values in the first row of mat. In your example, this first row is [7 11 3], and the second row is [3 4 5]. The outputs you're seeing are the sums of all values in each row (7+11+3=21).

What is the meaning of a matrix exponent of a scalar in MATLAB [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 5 years ago.
Improve this question
For a scalar c and a nxnmatrix A, what is the meaning of c^A?
E.g.
>> c=2;
>> A=[1 2; 3 4];
>> c^A
ans =
10.4827 14.1519
21.2278 31.7106
All I could find was this section in the Mathworks documentation.
But what is the real meaning of that, is this a commonly accepted definition? Is this useful in real applications?
Any reference to a document with further details is appreciated.
(I am aware of the element-wise operation c.^A)

Two dimensional matrix in Perl [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Newbie's question: What does $matrix[$row][4]=1; mean in a code? The row and column are known to me. Why is it made equal to 1?
The command will set the cell at position $row,4 with the value 1
= is the assignment operator in Perl. It assigns the value 1 to the cell at the coordinates $row, 4.
The comparison operators for equiality are eq for strings and == for numbers.

getting occurrence of alphabets in a string, in Matlab [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
i have to do huffman coding on a message read from a file,in Matlab.For that i have to find the probability occurrence of each alphabet in that message.Using that frequency i have to do huffman encoding.Can you please specify how to read a message from the file and store it as a string for the same purpose..Can anyone help me to solve this
What you need is a histogram count:
counts = histc(lower(x), 'a':'z');
where the output count contains the number of occurences for each letter in the message string x. For instance, the first element count(1) corresponds to the number of occurrences of a, count(2) corresponds to the number of occurrences of b, etc...
Also note that this x is converted to lowercase o make the counting case insensitive.

How can I fetch all the elements in A but not in B? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
In MATLAB, how can I fetch all the element in A but not in B?
If
A = [1 2 3 4 5 6 7 8];
B = [1 2 3];
I hope the answer to be [4 5 6 7 8].
It sounds like you need setdiff().
As Oli stated you can use setdiff, however a little faster way to perform the same operation is
C = A(~ismember(A, B));
setdiff also sorts the resulting array, if you need this you have to sort C in the above statement