Solved


Replace secondary diagonal elements of a square array
Replace all the secondary diagonal elements of the square array A with the number n Example: A=[1 2 3; 4 5 6; 7 8 ...

11 years ago

Answered
Conversion of for loop to Vector.
Here is something that I believe does the same as your code. Added bonus, it's got comments: ll = 20; %size of matrices, ma...

11 years ago | 1

| accepted

Answered
sum of function handle
_"I need to write it as function handle"_. Why do you *need* it? As Adam says, work it out as a normal function. Anyway: ...

11 years ago | 0

Answered
Search for a part of a string in cell of cell array
VarNames = {'Trend 1 - abc def', ... 'Trend 2 - ghi mmm jkl', ... 'Trend 3 - mno ttt kkk pqr', ....

11 years ago | 1

Answered
Auto Squeeze Problem in Array Indexing
What is the reason behind your request? It's something odd to want. I don't think it's possible. Matlab automatically removes...

11 years ago | 0

Answered
How to obtain histogramof each individual matrix in cell array?
In its simplest form: cellfun(@histogram, yourcellarray); If you want to specify the number of bins or edges nbins ...

11 years ago | 0

| accepted

Answered
how to do this calculation not by 'for' cycle?
One possible way to do it: data = [1 1 1 53.1100 1 2 2 59.0900 2 1 2 71.3100 ...

11 years ago | 0

| accepted

Answered
How to generate only four normally distributed random numbers with given mean and std. deviation?
That's statistics, it only works properly if the sample size is large enough. With two constraints (mean, and std) only two o...

11 years ago | 2

| accepted

Answered
Find borders of a truth map
The way you've defined your edges they correspond to either transition from 0 to 1 or from 1 to 0 when scanning from left to rig...

11 years ago | 0

| accepted

Answered
fopen works fine in *.m but fails in compiled Matlab
One important rule when dealing with user input, filesystem or anything else that is external to your program is to *always* mak...

11 years ago | 0

| accepted

Answered
Averaging data in several columns within certain intervals of data
Assuming you have a fairly recent version of matlab (2015a or newer), what you want to do is very easy: use <http://www.mathwork...

11 years ago | 1

Answered
Dynamically name a struct
While it is possible to generate variables dynamically (just use |eval|) it's not recommended practice. Generating the variable ...

11 years ago | 0

| accepted

Answered
I have a matrix with 161*2 with one column as distance to say x- axis and y- axis to be corresponding height. But I would like to scale the x-axis to 10000 points and I want particular height at a particular distance?
Use <http://uk.mathworks.com/help/matlab/ref/interp1.html interpolation>: heightdistance = [116 0.1333; 117 0.1; 118 0.0667...

11 years ago | 0

Answered
Matlab residue command not working ,,,,, ?
_"Anything I can do to have my expected answer ??"_ Increase the size of your command window, or scroll up? Alternatively...

11 years ago | 0

| accepted

Answered
[2x1^2+2x1x2+x2^2-10x1-10x2]
Assuming that |2x1^2+2x1​x2+x2^2-10​x1-10x2| actually means |2*x1^2 + 2*x1*x2 + x2^2 - 10*x1 - 10*x2|, multiplication signs are ...

11 years ago | 0

Answered
please i was trying to test a function that i have coded, but this message "subscripted assignment dimension mismatch" keeps appearing for every attempt. can someone help
I've not tried to understand your code, but |sol| is defined as a matrix with *1 row* and *n columns*: sol = zeros(1, n); ...

11 years ago | 0

Answered
How to manipulate a cell array
First, note that while your code works, conceptually, there is a bug. The splitting of the non-numeric entries should read: ...

11 years ago | 0

Answered
How to jump to different sections of program?
You could possibly code your decision tree as a state machine: %states: each row of the states cell array corresponds to a ...

11 years ago | 1

Answered
How to delete multiple rows if multiple conditions hold true
You need to use <http://www.mathworks.com/help/releases/R2015b/matlab/ref/any.html |any|> to reduce your 2d logical array to a c...

11 years ago | 1

| accepted

Answered
import data function breaks at NaN or not a number
With format like this you have no choice but to write your own parser. Here is a draft: function testresult = import_testre...

11 years ago | 0

| accepted

Answered
I am confused about array multiplication and divistion
dotted operations (so, |.*| and |./|) are memberwise operations, that is the 1st element of each operand are multiplied (or divi...

11 years ago | 0

Answered
Vectorization of nested for loops for following code
By default, matlab creates double variables, therefore there's no need to convert |zeros|, |randi|, etc output to double. (and i...

11 years ago | 0

| accepted

Answered
How to find a specific row in a matrix and eliminate it?
It looks like you don't care about the ordering of the columns. In that case, it's extremely simple: a) |sort| the rows (so that...

11 years ago | 0

| accepted

Answered
A for loop implementation... given matrix A=299x10, calculate the autocorrelation for every row of Matrix A one at a time
If my reading of the |xcorr| doc is correct (I don't have the signal processing toolbox), you could just apply |xcorr| to the wh...

11 years ago | 0

| accepted

Answered
"str2mat is not recommended", but what is recommended?
You can just replace |str2mat| by |char| and it should work: for ... ticklabels = char(ticklabels, char(paramDisplay(...

11 years ago | 0

| accepted

Answered
Use Matlab to select specific nonzero values in cell array
First, please use valid matlab syntax for your examples. In particular don't use matrix syntax |[]| when you have cell arrays th...

11 years ago | 1

Answered
Frequency against every value
Bearing in mind that the number of _data_ greater than 4 also includes the number of _data_ greater than 4.1, what you are askin...

11 years ago | 0

| accepted

Answered
Need help to vectorize this small code
[u, v] = ndgrid(1-N/2:N/2); cube = u.^2 + v.^2; S = exp(1i*pi*l*cube)

11 years ago | 0

Answered
how to quantize a row matrix of 15 elements to 1024 levels and then code using 10 bits(binary)?
<http://www.mathworks.com/help/releases/R2015b/matlab/ref/discretize.html |discretize|> to do the quantisation, <http://www.math...

11 years ago | 1

| accepted

Answered
Why doesn't csvread work?
Note that playing around with matlab path (using |rehash|, or |addpath|, or ...) is *not* going to help in any way with your pro...

11 years ago | 1

Load more