Answered
Matrix multiplication of n function handles
*Solution* You can define an anonymous function inside of another anonymous function: @(f)@(x)f(x,1:100) which we can...

11 years ago | 1

Answered
how to open this file
You cannot use <http://www.mathworks.com/help/matlab/ref/dlmread.html |dlmread|> with that file because (as its documentation st...

11 years ago | 0

Answered
Convert date string to Date number error
When you read the <http://www.mathworks.com/help/matlab/ref/datenum.html |datenum|> documentation you will find that the correct...

11 years ago | 0

Answered
Undefined function 'times' for input arguments of type 'struct'.
There is nothing wrong with the variable |SOC_1| inside |maqi.m|: every instance performs some numeric operation. The problem is...

11 years ago | 0

| accepted

Answered
Why I got the error "Undefined operator '*' for input arguments of type 'function_handle"?
You need to _call_ the function |f|, like this: g=@(x)x*f(x)+4 |f| is a function handle, not a numeric value. Function h...

11 years ago | 14

| accepted

Answered
Find one array into another
Funnily enough <http://www.mathworks.com/help/matlab/ref/strfind.html |strfind|> is really good for this task: numel(strfin...

11 years ago | 0

Answered
What's the difference between interp3 and scatteredinterpolant?
The figures in the MATLAB documentation should help you to understand the difference: <http://www.mathworks.com/help/matlab/m...

11 years ago | 2

| accepted

Answered
How do you replace cells in one cell variable with another set of cells from another variable?
A(21:30) = B(21:30) where |A| is the original cell array, and |B| contains the new values. The solution is easy using basic ...

11 years ago | 1

Answered
how to remove negative numbers from a vector
Use basic logical indexing: >> A(A>=0) ans = 5 0.1 0 100

11 years ago | 5

Answered
what does y(:,1) means if y is a matrix ?
Y(:,1) % the first column of Y Y(:,2) % the second column of Y This is basic MATLAB indexing: <http://www.mathworks.com...

11 years ago | 1

Answered
Error : Undefined function or variable xdot
*Solution* Put this before your third |for|-loop: xdot = NaN(1,2*ngg); This is called <http://www.mathworks.com/help/...

11 years ago | 0

Answered
replace first elements from 1 col to numbers
chr = 'BDEFGHIJOPQZ'; num = 10+(0:numel(chr)-1); org = strcat('^',[{'null'};num2cell(chr(:))]); rep = [{'0'};cellstr(...

11 years ago | 1

| accepted

Answered
When faced with the same value in a vector, what can you do to choose one over the other?
I would use <http://www.mathworks.com/help/matlab/ref/randperm.html |randperm|>: %A = [1;5;2] A = [5;5;2] B = NaN(3,6...

11 years ago | 0

| accepted

Answered
How to make a vector out of user input data?
pmt = 'Enter a finite number value (or any letter to exit): '; vec = []; while nnz(isfinite(vec))<2 || isfinite(vec(end)...

11 years ago | 1

Answered
How to arrange grid data?
>> X = [NaN 21 22 23 24 25 65 1 5 7 8 9 66 3 8 4 9 1 67 5 8...

11 years ago | 0

| accepted

Answered
How to write a circulation when save selected data into new matrix and then save new matrix into a text file
The trick is *do not create numbered variables*: fid = fopen('12345.txt','wt'); for k = 1:numel(res) idx = find(r...

11 years ago | 0

| accepted

Answered
How to calculate time elapsed
>> s1 = '2/4/2016 1:53:19.180 AM'; >> s2 = '2/4/2016 1:54:49.368 AM'; >> t1 = datevec(s1,'dd/mm/yyyy HH:MM:SS.FFF AM'); ...

11 years ago | 0

| accepted

Answered
i need an matlab coding for convert a binary value into hexadecimal value? here am having a code for hexa to binary, now i need the decryption process (i.e.,)binary to hexadecimal values.
col = 'C0C0C080008000ff00ff00ffFF6347FFA5009ACD32FFD700FFA500BDB76B9ACD32F0E68CBDB76BDAA520B8860BFFA5009ACD32FFA072FFD700FFA50...

11 years ago | 0

Answered
I would like to select the values from my 2nd column which have the less than 5 value in the 1st column. So my matrix looks maybe like this:
Use <http://www.mathworks.com/help/matlab/math/matrix-indexing.html logical indexing>: >> M = [ 3 5 8 2 6 4 10 6 1 9 2 6; 1...

11 years ago | 0

| accepted

Answered
create equation from polyfit
A pure numeric solution is very easy using <http://www.mathworks.com/help/matlab/ref/polyval.html |polyval|> and <http://www.mat...

11 years ago | 0

Answered
i have a 4x4 matrix of doubles that i want to check each element with isprime(x) and if yes replace with P and if not replace with X to form a matrix the same size with char. using nested for loops
Why waste MATLAB's abilities by trying to use slow, ugly nested loops? Those loops are not required and have just made the whole...

11 years ago | 1

Answered
Flipping the numbers 1 to -1
Try using a |while| loop: a = ones(1,4) k=1; mag=[]; while k<=numel(a) x = rand()>=0.5; a(k)=a(k)-2*...

11 years ago | 0

| accepted

Answered
How can i decrypt the encrypted UNICODE values of name,dob,number,date and place? here i include the code below...
Just use <http://www.mathworks.com/help/matlab/ref/sprintf.html |sprintf|> and <http://www.mathworks.com/help/matlab/ref/sscanf....

11 years ago | 1

Answered
how to convert cell into matrix
>> a={[1 2 3],[2 3 4;1 2 3]} a = [1x3 double] [2x3 double] >> vertcat(a{:}) ans = 1 2 3 ...

11 years ago | 0

| accepted

Answered
How do I save my answers with 2 for loops.
Using <http://www.mathworks.com/help/matlab/ref/bsxfun.html |bsxfun|> is faster and neater than using loops: >> X = bsxfun(...

11 years ago | 0

| accepted

Answered
Extrapolate a specific group of numbers and letters from a "char" variable.
>> fmt = '.*(P\d{3}).*(L\d{4}).*'; >> regexp('20upg13 D112-A104 FH08547 P800 L0600@10000 a.csv',fmt,'tokens','once') ans...

11 years ago | 2

| accepted

Answered
Hi how can id do this plot f = 5sin⁔(10pi*t) over one period
>> N = 200; >> t = linspace(0,2/10,N); >> v = 5*sin(10*pi*t); >> plot(t,v) creates this: <</matlabcentral/answe...

11 years ago | 0

| accepted

Answered
How Do I find unique values of an element in a matrix
Use <http://www.mathworks.com/help/matlab/ref/accumarray.html |accumarray|>: >> A = [5,12,25,0;2,10,24,0;1,7,25,1;5,5,12,0;...

11 years ago | 0

| accepted

Answered
If isnan(x) make columns also NaN
This is trivial using basic MATLAB indexing: >> A = [1,2,3;4,5,6;7,8,9] A = 1 2 3 4 5 6 7 8...

11 years ago | 0

Load more