Answered
add blank spaces in cell array
>> ar = [0,1,0,0,0,0,0,0,0,0;0,0,0,3,0,0,0,0,0,0;0,0,0,0,0,0,2,0,0,0;0,0,0,0,0,0,0,0,3,0;4,0,0,0,0,0,0,0,0,0] ar = 0 ...

8 years ago | 0

Answered
how do i discretize negative integers
_"This works for positive integers only"_ Actually |histc| works perfectly for negative values. It works for me: >> x = ...

8 years ago | 1

| accepted

Answered
Strange problem with sin.
_"Strange problem with sin."_ So what _is_ the problem? You did not tell us what you _expect_ to get for the output values, o...

8 years ago | 0

| accepted

Answered
In a sorted vector ,how do I compare first element to other elements and then find if there are any duplicates , if yes take their indexes and replace it with 0
For a sorted row vector. Find duplicates of the first element, as you requested: >> A = [1,1,2,3,4]; >> X = A(1)==A; ...

8 years ago | 1

| accepted

Answered
How to rename an array inside an .mat file?
_"I have 8 separate files with an array in each. I am trying to import them but they all have the same array name. How do I chan...

8 years ago | 0

Answered
Help with an error occurring
The only mention of |displayWaveformLabels| I can find is on this page: <https://www.mathworks.com/help/signal/examples/wavef...

8 years ago | 1

| accepted

Answered
Managing several GUIs through a script
_"I'm pretty sure I can do it with global variables but I'm trying to avoid using them"_ Avoiding global variables is a good ...

8 years ago | 1

| accepted

Answered
How can I index these matrix blocks into numbers?
Actually you can already access it like you want, using linear indexing. Try it: C{1} C{2} ... C{16} Here is a ...

8 years ago | 0

| accepted

Answered
Extract part of string using REGEXP
Use a look-around operation to ensure that the previous character was alphanumeric: >> C = {'R44821_181026120003i3t001B02f0...

8 years ago | 0

| accepted

Answered
How to plot for a matrix?
You for to use the index |k| from the outer loop: % Fitzhugh-Nagoma model parameters e = 0.01; k = 1:1:4; a = 0.1;...

8 years ago | 0

| accepted

Answered
Converting the Cell array Contents to Matrix
Where |C| is your cell array: [C{:}] or horzcat(C{:}) Depending on the required order you might need to transpos...

8 years ago | 0

| accepted

Answered
Need help concatenating data with struct field name?
Create a cell array from the structure field: names = {s.name} This syntax uses a comma-separated list: <https://www....

8 years ago | 0

| accepted

Answered
How do i get my graph to produce a straight line other than just points? Thanks.
The basic problem is that you are plotting individual points inside a loop. This approach will never get you a joined-togethe...

8 years ago | 0

Answered
Create a vector by selection randomly vectors
Having separate vectors is a pain to work with, so the first thing to do is to put them into one matrix |M|: >> M = [1,2,3,...

8 years ago | 2

Answered
How to replace parts of the text using regexprep
This uses a slightly different approach using |regexp| and |strncmp|, which is based on the assumption that each command is on i...

8 years ago | 0

| accepted

Answered
How to read name of a recently imported struct
_"What I currently do is loading the file by giving the name, than reading the struct name by myself and writing it manually int...

8 years ago | 0

Answered
looping a for loop through an array
Where |V| is your 105120X1 vector of data: mean(reshape(V,12,[]),1); And checking using random data: >> V = randi(9...

8 years ago | 0

Answered
How to use if statement to compare strings
gI = ''; while ~ismember(gI,{'m','f'}) gI = input('Enter gender: ','s'); end

8 years ago | 0

Answered
Why is my for loop not iterating in the way I want?
N = 2; % the value to use. % Approximation: X1 = 1:12; % the number of terms. Y1 = nan(size(X1)); for k = X1 ...

8 years ago | 0

| accepted

Answered
i have a cell array storing few hundred vectors, how can i write them each line with only one vector to a file.txt without floats?
A simpler solution is to convert your data into one numeric matrix and use |csvwrite|: C = {[1,2,3,4],[2,3,4,5],[3,4,5,6]};...

8 years ago | 0

Answered
How to fix my recursive function?
function out = moreFactors(a,b,fact) ixa = fix(a)==a; % test if integer. ixb = fix(b)==b; % test if integer. if ixa ...

8 years ago | 0

| accepted

Answered
How to modify table elements without using a for loop?
Your original idea of using |strcmp| was perfect, there is no need to complicate things with strings: value = [1;2;3;4] ...

8 years ago | 1

| accepted

Answered
Variable input using a flag
MATLAB returns arguments based on demand, so you can simply define all three of them: function [out1, out2, out3] = myFun(i...

8 years ago | 0

| accepted

Answered
Make the subfolders name in output folder the same input folder
Do NOT use |cd|: this is a slow and inappropriate for reading/writing data. You should just use absolute/relative filenames gene...

8 years ago | 0

| accepted

Answered
Can someone help me write this into a series?
r = pi; n = 4; S = sum((2:2:2*n).*r.^(3:2:2*n+1)) Or r = pi; n = 4; v = 2:2:2*n; sum(v.*r.^(v+1))

8 years ago | 0

Answered
Colormap engineering to highlight small values
You will need to either: # scale the values before plotting (e.g. log/exp), or # create/find a suitable colormap that highli...

8 years ago | 1

Answered
How to process multiple .csv files?
You have a variable named |length|. This means when you write this: for k = 1 : length(theFiles) you are telling MATLAB ...

8 years ago | 0

| accepted

Answered
Shifting column of a matrix with maximum sum to the right?
>> M = randi(9,4,7) % fake data M = 9 5 5 1 6 9 4 3 5 8 9 1 5 2 2 ...

8 years ago | 0

| accepted

Answered
How to specify path in MATLAB?
<https://www.mathworks.com/help/matlab/ref/fgetl.html |fgetl|> only has one output argument, so calling it with two will throw a...

8 years ago | 0

| accepted

Answered
msg=dec2bin(32,8); encode_data=encode(msg,14,8,'cyclic');but it appears an error like "Output argument "code" (and maybe others) not assigned during call to "encode". Error in cyclic_code_check (line 12) encode_data = encode(msg,n,k,'cyclic')"
There are some differences between your two function calls: # character vs. numeric |msg|. # vector vs. matrix |msg|. App...

8 years ago | 0

| accepted

Load more