Answered
Print the value number shown in the workspace ?
Just use <http://www.mathworks.com/help/matlab/ref/size.html |size|>: size(PHI,1) MATLAB does not have any command |fpri...

11 years ago | 0

| accepted

Answered
how to give range of values to variable
Why use slow and ugly loops? This is MATLAB! s = 0:255; Note that MATLAB uses one-based indexing, so |s(0)| is an error....

11 years ago | 8

Answered
Hello all,I am trying to solve this in command window f = @(X)((x.^3)-2*(x.^2)-5*(x-3))*exp(x); Xn = (1:15)/16; fXn = f(Xn) And i am getting following error: Error using ==> mpower Matrix must be square.
This fixes the error, but only _you_ can check if it is _correct_: >> f = @(x)((x.^3)-2*(x.^2)-5*(x-3)).*exp(x); >> f(1:...

11 years ago | 0

| accepted

Answered
How to create a matrix of numbers from workspace variables?
Yes there _is_ an efficient way to do this: *don't create 70 numbered variables in your workspace*. How did you "create" them...

11 years ago | 1

Answered
How do I plot real and imaginary parts on one graph(figure)? And how do I do that separately?
Without syms is simpler: X = 400:600; E = 1-(9.1./(((6*pi*10.^8)./X).^2+0.005184)) + 1i*(5.96232./(((6*pi*10.^8)./X).^3+...

11 years ago | 0

Answered
Changing back to original folder after an error occured
The best solution is *do not change directories*. There is rarely a reason for doing this. If you only need to access files in t...

11 years ago | 2

| accepted

Answered
List of indexes for each row of a matrix without a for loop
>> S = size(INDSETS); >> reshape(DATA(:,INDSETS).',S(1),S(2),[]) or on one line: >> reshape(DATA(:,INDSETS).',[size...

11 years ago | 1

| accepted

Answered
How to find which elements for each row of matrix B (NxM) are contained in matrix A (NxK), in their corresponding row n using vectorization?
No loops are required. *Method one: |permute|* >> any(bsxfun(@eq,B,permute(A,[1,3,2])),3) ans = 0 0 0 1 ...

11 years ago | 0

| accepted

Answered
extracting row and column indices from MatLab matrix
D_input = [0 1 2 1 ; nan 0 2 1 ; nan nan 0 1 ; nan nan 1 0] S = size(D_input); [X,Y] = ndgrid(1:S(1),1:S(2)); fpr...

11 years ago | 2

Answered
Calculate monthly averages without reshaping
Note: this code works if |date| is a cell array of strings, and also if |date| is a numeric vector of values representing year a...

11 years ago | 1

| accepted

Answered
Matrix Manipulation code help
For a simple generalized solution use <http://www.mathworks.com/help/matlab/ref/bsxfun.html |bsxfun|>: >> t = [1 1 1 3 1 2 ...

11 years ago | 0

Answered
1D array combinations
This will generate a cell array of all <https://en.wikipedia.org/wiki/Combination combinations> of all possible lengths: C ...

11 years ago | 1

| accepted

Answered
How to remove some certain rows in Matlab?
Simple logical operations are all that is required: >> idx = all(1==A(:,2:end),2); >> B = A(~idx,:) B = 45 ...

11 years ago | 0

| accepted

Answered
"Subscripted assignment dimension mismatch" Please correct my program. tell me idea/logic to make sequence
Don't waste time with all of those loops when you can simply use <http://www.mathworks.com/help/matlab/ref/hankel.html |hankel|>...

11 years ago | 1

| accepted

Answered
find the closest element in each row of an array to each element of a vector?
>> [err,idy] = min(abs(bsxfun(@minus,b,reshape(a,1,1,[]))),[],2); >> idx = repmat((1:size(b,1)).',1,size(b,2)); >> idz =...

11 years ago | 2

Answered
Error using cd Argument must contain a string
Don't use |cd| for trivial code like this: simply construct the filepath using <http://www.mathworks.com/help/matlab/ref/fullfil...

11 years ago | 0

| accepted

Answered
How look for value inside Cell_array?
Try this: % fake data: for k = 10:-1:1 inp{k} = repmat(randperm(16),25,1); end % extract only columns that ...

11 years ago | 0

| accepted

Answered
Sorting a directory of txt files.
My FEX submission natsortfiles was written to deal with this exact problem: >> S = dir('*.txt'); >> S.name ans = '1.txt'...

11 years ago | 0

Answered
How to remove zeros from an array????
Simply use logical indexing directly on |a| (those |b| variables are not required): >> a(~ismember(a,y)) ans = 4 ...

11 years ago | 1

| accepted

Answered
hi every one, i am new in matlab and i need some help in using random number to calculate pi ??
This is a task that has been described and solved many times: <http://www.mathworks.com/matlabcentral/answers/265420-i-m-new-...

11 years ago | 1

| accepted

Answered
Remap values of 256x256 array based on ranges
The basic problem is that both <http://www.mathworks.com/help/matlab/ref/logicaloperatorsshortcircuit.html logical short-circuit...

11 years ago | 0

| accepted

Answered
How to remove empty spaces in between text in a cell array?
Just use <http://www.mathworks.com/help/matlab/ref/strrep.html |strrep|>: >> Data={'Symbol','Date','Expiry','Open','High','...

11 years ago | 0

| accepted

Answered
Is it possible to multiply elements in a matrix greater than a certain value without using a loop?
*Method One: Simple* exponent in just one line: >> X = [1 2 3; 4 5 6; 7 8 9]; >> Y = X .* 2.^(X>1) Y = 1 4 ...

11 years ago | 1

Answered
I have a 6000x9424x50 matrix and want to convert it into 6000x9424x10 and 6000x9424x20?? I meant to to split 50 bands to 10 or 20 bands individually?
For the most generalized solution use <http://www.mathworks.com/help/matlab/ref/mat2cell.html |mat2cell|>: >> X = rand(600,...

11 years ago | 0

Answered
Output argument "row" (and maybe others) not assigned during call to "D:\matlab\findcircle.m>findcircle".
You specify that the function |findcircle| has outputs |row|, |col| and |r|, but these are never defined inside the function: ...

11 years ago | 0

Answered
How to insert space to a string given
As long as you know the locations of the space characters, then it is easy to recreate the original string: >> str = 'MY FI...

11 years ago | 1

Answered
Matrix dimension Error while attempting to divide
This works without error: c = (f.^2) .* ( (2.687/(10000000000000)) + ((7.858/100) ./ ((f.^2)+1.226)) + ((1.481/10000) ./ ((...

11 years ago | 0

| accepted

Answered
How to sort the components of a vector?
Use <http://www.mathworks.com/help/matlab/ref/sort.html |sort|> sort(vec)

11 years ago | 0

| accepted

Answered
convert frames into video. Previous code i took frames from video, edited them and now i want to put them back. I got code from previous answer but it isnt working. Thanks
Why not read the error message and do exactly what it tells you to do? The message is quite helpful: _"Call open(obj) before cal...

11 years ago | 1

| accepted

Load more