Answered
generate a summation series
>> X = 1+cumsum(2:999); % 1+[2,3+2,4+3+2,...,999+..+2] >> Y = 3:1000; % [3,4,5,...,1000] >> sum(X.*Y) ans = ...

11 years ago | 0

| accepted

Answered
How correctly use fprintf
*Textfile Newlines* Try adding |'t'| to the <http://www.mathworks.com/help/matlab/ref/fopen.html |fopen|> permissions string:...

11 years ago | 1

| accepted

Answered
Uppercase string from the cell array
regexp(a,'^[^a-z]+$','match')

11 years ago | 1

| accepted

Answered
How to write this simple script correctly?
Simply using logical indexing: >> s = [1,0,1;0,0,0]; >> b = [2,3,4]; >> out = repmat(b,size(s,1),1); >> out(s==1) ...

11 years ago | 1

| accepted

Answered
How can I merge two Image?
This sounds like a kind of <https://en.wikipedia.org/wiki/Interlacing_(bitmaps) image interlacing>. Try this: >> A = [1,2;3...

11 years ago | 1

| accepted

Answered
[a,b]=[1,2] why does not work? How I correct it?
The documentation for <http://www.mathworks.com/help/matlab/ref/specialcharacters.html |[]|> clearly describes it as being a _co...

11 years ago | 2

| accepted

Answered
how to save a matrix in a loop together whose size is changing?
You could put the matrices into a <http://www.mathworks.com/help/matlab/cell-arrays.html cell array>: B = cell(1,5); for...

11 years ago | 1

| accepted

Answered
How to fix a randomly generated sample in Matlab after making some changes to the code?
You can use <http://www.mathworks.com/help/matlab/ref/rng.html |rng|> to control the random number generation, for example (from...

11 years ago | 0

| accepted

Answered
Call both outputs of a function in a for loop
Instead of this: cost_matrix(i1) = {VirtualPPDispatch(curCell1)}; Try this: [tmp1,tmp2] = VirtualPPDispatch(curCell...

11 years ago | 0

| accepted

Answered
Concatenate matrices into one matrix .... basic problem
You can read more in the <http://www.mathworks.com/help/matlab/ref/specialcharacters.html |[]|> and <http://www.mathworks.com/he...

11 years ago | 0

Answered
Replacing numbers around a specific index(CAN'T FIGURE IT OUT)
It can be done very easily by converting the integers to |char| and using |regepxrep|: >> A = repmat(99:-1:1,1,9); % fake d...

11 years ago | 0

Answered
Multiplying the row numbers and column numbers, NOT THE ELEMENTS iN THEM
Standard <http://www.mathworks.com/help/matlab/ref/mtimes.html matrix multiplication> does exactly what you need: >> C = 1:...

11 years ago | 2

Answered
How to add data to an existing txt file which already contains some lines ?
Read the <http://www.mathworks.com/help/matlab/ref/fopen.html |fopen|> documentation and have a look at the permission options. ...

11 years ago | 0

Answered
How to write function according to variables? fminspleas
Rather than using the ugly and evil <http://www.mathworks.com/help/matlab/ref/eval.html |eval|>, simply define some <http://www....

11 years ago | 0

| accepted

Answered
How to get values assigned to a string?
Ugh... bad idea! Avoid creating dynamically named variables in MATLAB. This is poor practice as has been explained many times...

11 years ago | 1

Answered
Arrange element according to its index
Easy: >> a = [3,4,5,6,7,9]; >> b = [2,4,1,3,5,6]; >> x(b) = a x = 5 3 6 4 7 9

11 years ago | 1

| accepted

Answered
[Questions] Logical Indexing Problem
The task states clearly that the _"function must use logical indexing instead of explicit looping"_, and using logical indexing ...

11 years ago | 0

| accepted

Answered
how to save all the data?
For no obvious reason you removed the |any| from my answer: Notdata = X(~any(idx,2),:);

11 years ago | 1

| accepted

Answered
How to imitate Matlab's plot function in plot function made by user?
Use <http://www.mathworks.com/help/matlab/ref/varargin.html |varargin|>: function my_fun(xvar, norm1, var1, varargin) pl...

11 years ago | 0

Answered
For loop or Array?
>> A = [0 0 0 0 1 1 0 0 0 0 0 1 1; 0 0 0 1 1 1 0 0 0 0 1 1 1; 0 0 0 1 1 1 0 0 0 0 1 1 1; 0 0 0 0 0 1 0 0 0 0 0 0 1] A = ...

11 years ago | 0

Answered
How to merge function handles in matlab?
You could use <http://www.mathworks.com/help/matlab/ref/arrayfun.html |arrayfun|> for this: fun = @(a,b,n) arrayfun(@(nn)fk...

11 years ago | 0

| accepted

Answered
How to Unnest Nested cell arrays
Given your array |X|: X(:,17) = vertcat(X{:,17}); Note that this will only work if *all* of the cells in that column con...

11 years ago | 0

| accepted

Answered
Create a new vector with specific values from other vector
>> V = 'a':'t' V = abcdefghijklmnopqrst >> fliplr(V(end-5:-6:1)) ans = cio

11 years ago | 0

| accepted

Answered
search for a word in a cell
It seems that you want to collect together the rows of the file data that contain a particular word (e.g. "Battery"). Here is ho...

11 years ago | 1

| accepted

Answered
Get the Array Number, when value changes
Try this: X = {1,'Monday';2,'Monday';3,'Monday';4,'Sunday';5,'Sunday';6,'Monday';7,'Monday'}; Y = [true;any(diff(char(X(...

11 years ago | 0

Answered
Finding the maximum values of four variables and nine participants
The basic cause of the problem you are seeing is that the |File| and |MaxT| calulations are inside the |switch| case for |'RKnee...

11 years ago | 0

Answered
How to check if a line contains only numbers?
>> spl = regexp('115;125to129;155','(\d|;|to)*','split'); >> isempty([spl{:}]) ans = 1 >> spl = regexp('115a;...

11 years ago | 0

| accepted

Answered
Questions about 64-bit stuff
The core difference is this: * floating point classes (e.g. <https://en.wikipedia.org/wiki/Double-precision_floating-point_fo...

11 years ago | 0

Answered
Problem using cd in MATLAB function
The syntax home = cd; is possibly not valid: it is not covered by the online documentation. The best solution is to avo...

11 years ago | 1

| accepted

Answered
how to remove some unwanted characters winthin a string
Try using <http://www.mathworks.com/help/matlab/ref/regexprep.html |regexprep|>, something like this should work: regexprep...

11 years ago | 0

| accepted

Load more