Answered
How to count number of pcwrite when I want to save file
better to use |sprintf|: str = sprintf('Plane %d',loop); pcwrite (plane, str, 'PLYFormat', 'binary'); or using |num2s...

9 years ago | 0

| accepted

Answered
Why does matlab save strings from delimited text file as individual characters? And how to prevent.
Rather than wasting time importing the data as character, you would be much better of using <https://www.mathworks.com/help/matl...

9 years ago | 0

| accepted

Answered
Search string for special characters
It is invariably easier to build a short list of the _permitted_ characters than an long (and most likely incomplete) list of _f...

9 years ago | 0

| accepted

Answered
In this question, would dig be 2 inputs, such as 91 and 99? And lim can be any number the user calls?
I know that this is homework, but someone needed to demonstrate how this can be done quite simply, without using slow and unnece...

9 years ago | 6

| accepted

Answered
using a structure as a global variable
DO NOT USE GLOBALS. You could avoid the whole problem by not using globals. Just because some beginners like to use global va...

9 years ago | 2

| accepted

Answered
Use ode values without storing
Write your own output function, which is called by |ode45| after each successful step: <https://www.mathworks.com/help/matlab...

9 years ago | 0

| accepted

Answered
How to place the minimum value of a 3*3 matrix at center of the matrix.?
This is easy with linear indexing: >> X = [56,57,90;98,79,49;20,30,39] X = 56 57 90 98 79 49 20 30...

9 years ago | 0

Answered
matrix repetition on diagonal
I suspect you might want something like this: >> T = [1,0;1,1]; >> N = 4; >> R = zeros(1,N); >> C = zeros(1,N); ...

9 years ago | 3

Answered
Is it possible to get a consistent colour scale across subplots? Rather than one that is relative to each plot..
Use <https://www.mathworks.com/help/matlab/ref/caxis.html |caxis|> to control the limits used for scaling the colormap to the da...

9 years ago | 1

| accepted

Answered
Gradient is zero yet exists
Why would you expect >> gradient(140,150) ans = 0 to be non-zero? You are asking for the gradient at one point... to ...

9 years ago | 0

| accepted

Answered
select several groups in a Vector
*Method one: |diff| and |arrayfun|:* >> x = [0 0 0 1 1 1 0 0 1 1 0 1 1 1 0 0 0 0 1 1 1 1]; >> d = diff([0,x,0]); >> C...

9 years ago | 1

| accepted

Answered
How can I select specific letters in a name?
>> str = 'Savannah''s new snowmobile'; *Method one: logical comparison:* >> nnz('s'==lower(str)) ans = 3 *Metho...

9 years ago | 0

| accepted

Answered
How to create a matrix of size N×N that has ones in the border and zeros inside?
M = ones(5); M(2:end-1,2:end-1) = 0

9 years ago | 5

Answered
How to change the output file name with the same input file name but with a different extension ?
Use <https://www.mathworks.com/help/matlab/ref/fileparts.html |fileparts|> to get the filename without the extension: >> ol...

9 years ago | 0

| accepted

Answered
How to scan a sentence of text, one by one word and store it in seperate memory location?
Use <https://www.mathworks.com/help/matlab/ref/regexp.html |regexp|>, and adapt the regular expression to suit whatever your def...

9 years ago | 0

| accepted

Answered
Interp2 yields undesired results on center daigonal.
There is nothing wrong with |interp2|. Here is a minimal working example of your situation: >> interp2([0,1;1,0]) ans...

9 years ago | 1

| accepted

Answered
An n-by-n square logical matrix can be represented by a cell vector of n elements where the kth element corresponds to the kth row of the matrix. Each element of the cell vector is a row vector of positive integers in increasing order representing th
The question introduces the idea that data can be compressed by storing meta-data about the data: in this case, rather than stor...

9 years ago | 1

| accepted

Answered
How fprintf cell array and martix?
Avoiding the |for| loop is quite easy too: C = xx.'; C(2,:) = num2cell(yy); fprintf('%s %3.1E \n', C{:}) which pri...

9 years ago | 2

Answered
Remove empty sets in iteration to avoid indexing error?
# Put |find|'s outputs into two temporary variables. # Use an |if| to check if the variables are empty of not, and... # inside...

9 years ago | 0

| accepted

Answered
Problems with ode45, Input arguments to function include colon operator. To input the colon character, use ':' instead.
A function handle is not an array, so it is unclear what you imagine indexing would do to a function handle. You are basically d...

9 years ago | 0

Answered
Extraction of row information of a mixed cell array with strings based on multiple conditions.
_"Im still quite new to MatLab and have spent almost the whole day to no avail in figuring this out"_ Storing numeric data in...

9 years ago | 1

| accepted

Answered
how can i create matrix for all possible combination?
Use <https://www.mathworks.com/help/matlab/ref/ndgrid.html |ndgrid|>: >> [deltaM,phiM] = ndgrid(delta,phi); >> [phiM(:),...

9 years ago | 1

| accepted

Answered
How can i create a column matrix as mentioned bellow of n elements.
A = 0.5*ones(n,1) or A = ones(n,1)./2 or A = 0.5+zeros(n,1)

9 years ago | 1

Answered
Can somebody tell me where I went wrong with this code?
There are some bugs in the first few lines of code. function msg= grade_app(score) score = 'Enter number between 0 and 1...

9 years ago | 0

| accepted

Answered
i am working on a serial data and need to convert it from serial to parallel data.i have a matrix of 7500 x 1, and i need to divide it into 10 individual matrices of 750 x 1.
It is simple to split a matrix into matrices in a cell array using <https://www.mathworks.com/help/matlab/ref/mat2cell.html |mat...

9 years ago | 0

| accepted

Answered
Add index matrix to matrix
You can do this very simply inside the loop, there is no need to use cell arrays, slow |cellfun|, or |repelem|. out = NaN(0...

9 years ago | 2

Answered
Nested function not assigning value to global variable
Get rid of the |global|. Globals do not solve anything, no matter how much beginners love using them. It is not clear what...

9 years ago | 2

Answered
How to insert a int value into the name of a variable (for loop)
Just use a <https://www.mathworks.com/help/matlab/matlab_prog/access-multiple-elements-of-a-nonscalar-struct-array.html non-scal...

9 years ago | 0

| accepted

Answered
How can I count the number of other elements between two specific elements in a matrix?
Assuming that there are only two ones per row: >> sum(cumsum(A,2)==1,2)-1 ans = 0 2 4 4 2 ...

9 years ago | 1

| accepted

Answered
sorting cell array ascending
Download my FEX submission <https://www.mathworks.com/matlabcentral/fileexchange/47434-natural-order-filename-sort |natsort|>. T...

9 years ago | 1

Load more