Answered
extracting variable from callback into base workspace
"However, I have seen experts saying assignin() is not a good suggestion." assignin should definitely be avoided, as should any...

8 years ago | 0

| accepted

Answered
How do I get the maximum numbers of every "increasing pattern" in each row in a matrix?
>> A = [1,2,3,1,2,3,4,1,2,1,2,3,4,1,1;1,2,1,1,2,3,1,2,3,4,1,2,3,4,5] A = 1 2 3 1 2 3 4 1 2 1 2 3 4 ...

8 years ago | 1

| accepted

Answered
How to get Random numbers only from -1 1 and 2?
The easiest way is to define a vector of the values that you want and use (random) indexing: >> V = [-1,1,2]; >> V(randi(numel...

8 years ago | 1

| accepted

Answered
I have a .mat file that is a (1 x 1) struct with 3 fields and every fields is a (54057 x 2) double array. How i can plot this structure?
There is no need to use a loop: plot3(Data.mocap_x,Data.mocap_y,Data.mocap_z)

8 years ago | 0

Answered
Not enough input arguments.
You defined the function HiopH with two input arguments: function ph = HionpH (pH,b) In earlier threads we helped you to para...

8 years ago | 0

| accepted

Answered
Read mixed numbers in Matlab
opt = {'CollectOutput',true,'Delimiter',','}; fmt = repmat('%s',1,4); [fid,msg] = fopen('data.txt','rt'); assert(fid>=3,msg);...

8 years ago | 0

| accepted

Answered
How to vectorise the code below
Here are some vectorized versions of your functions: R = 5; A = [1,1,-1,-1,1;1,-1,-1,1,1]; B = cat(3,A(1,:),A(2,:)); for x =...

8 years ago | 1

| accepted

Answered
is there any function for adding zero ? related toa other matrix
>> A = [1,2,4,5;2,6,3,5;2,7,6,2] A = 1 2 4 5 2 6 3 5 2 7 6 2 >> B = [1,2;3,2] B = 1 2 ...

8 years ago | 3

| accepted

Answered
how to find resultant min Graph.
>> W = cat(3,A,B,C,D); >> R = min(W./(W~=0),[],3) R = 1 2 3 4 5 1 2 4 5 5 3 4 7 8 9

8 years ago | 1

| accepted

Answered
Avoid for loop?
Simpler: >> hankel(1:6,6:9) ans = 1 2 3 4 2 3 4 5 3 4 5 6 4 5 6 7 5 6 7 8 ...

8 years ago | 0

Answered
Issue in separating single channel from color image
"The issue is that image is shown as (almost) grayscale image instead of (expected) red(ish) image" It is possible that your ex...

8 years ago | 0

Answered
Matlab 2014b bug: Warning: Matrix is singular to working precision.
"I am getting wierd warning when I try to invert matrix" It is not weird at all: you confused how floating point numbers are di...

8 years ago | 2

Answered
All Possible Combinations of 2 vectors
>> [A,B,C,D,E] = ndgrid(1:5); >> M = [A(:),B(:),C(:),D(:),E(:)]; M = 1 1 1 1 1 2 1 1 1 1 3 1 1...

8 years ago | 0

| accepted

Answered
How to make vector increasing same value??
repelem([1,2,3,4],4)

8 years ago | 2

| accepted

Answered
need help vectorizing a complicated loop
If you change the size of the s, c and y vectors to 1x1x2000 then this is easy. For MATLAB version R2016b or later: s = rand(1,...

8 years ago | 0

| accepted

Answered
How to extract rows the first 4, skip 21 rows, and extract the next 4 rows
Where M is your matrix, adjust the constants to suit your needs: vec = 1+mod(1:size(M,1),21); idx = 1<=vec & vec<=4; out = M(...

8 years ago | 0

Answered
read files in a directory
This will read the data from one file (attached): [fid,msg] = fopen('sr36161v4.0.txt','rt'); assert(fid>=3,msg) % Preamble da...

8 years ago | 0

| accepted

Answered
How can I automatize the selection of multiple '.zip' files?
As the MATLAB documentation https://www.mathworks.com/help/matlab/import_export/process-a-sequence-of-files.html explains, you...

8 years ago | 0

| accepted

Answered
how to read data from characters?
https://www.mathworks.com/help/matlab/import_export/process-a-sequence-of-files.html D = 'path of the directory where those fil...

8 years ago | 0

| accepted

Answered
fast interp on 1 dimension of 3d matrix
Use interp3 or interpn: >> A = randi(9,5,7,3) A(:,:,1) = 3 3 5 3 8 1 2 8 7 3 4 9 9 2 3 5...

8 years ago | 0

| accepted

Answered
How to write a cell array of mixed strings and integers into a text file?
Where C is your cell array: C = {'GALK1',1;'ERCC2',1;'PGD',1;'PLK',1;0,0;0,0;0,0;0,0;0,0}; D = cellfun(@num2str,C,'uni',0).'; ...

8 years ago | 1

| accepted

Answered
How can I convert a matrix of numbers into a cell array of names?
It is simpler and much more effiicient to just use indexing: >> M = reshape(randperm(10),5,2) M = 7 10 5 4 ...

8 years ago | 0

Answered
Is there a quick and easy way to insert/delete values into the middle or beginning of a cell array and/or a numerical array
Just use indexing: >> V = randperm(9) V = 9 5 7 3 4 6 8 2 1 >> idx = 3; >> val = 0; >> V = [V(1:idx),va...

8 years ago | 0

| accepted

Answered
Hi guys how can swap the max value and min value for a matrix ?
>> A = randperm(9) A = 5 6 1 3 7 8 4 9 2 >> [~,idx] = max(A(:)); >> [~,idn] = min(A(:)); >> A([idx,idn])...

8 years ago | 0

Answered
Assigning blank cell array confuses Matlab with data type
x_cell = {single([])}; % assign. Note that your code expands the numeric array on each iteration, which is inefficient. It is r...

8 years ago | 1

| accepted

Answered
I would like to write a computation that will take a vector of 1xN length and then add adjacent matrix values .
Where V is your vector (containing an even number of elements): V(1:2:end)+V(2:2:end)

8 years ago | 0

| accepted

Answered
How to acieve a scatter plot like this.
One simple option is to use pcolor: >> M = randi([-3,6],5,7); >> M([3,4,5,9,10,15]) = NaN; >> pcolor(1:7,1:5,M) You ca...

8 years ago | 1

Answered
functions with different conditions
>> f = @(x) x.^2.*(x>1) + x.^4.*(x<=1); >> integral(f,0,2) ans = 2.5333

8 years ago | 2

| accepted

Answered
Is it possible to make an if-statement with multiple conditions (a vector of numbers)?
Use any: if any(B(1,i)==65:90) Or ismember: if ismember(B(1,i),65:90)

8 years ago | 0

| accepted

Answered
How can I merge many rows of different lengths into a matrix?
>> C = {1:2,3:7,1:10}; >> L = cellfun('length',C); >> M = zeros(numel(C),max(L)); >> for k = 1:numel(C), M(k,1:L(k)) = C{k}; ...

8 years ago | 0

| accepted

Load more