Solved


Remove all the words that end with "ain"
Given the string s1, return the string s2 with the target characters removed. For example, given s1 = 'the main event' your ...

10 years ago

Solved


Generate the sum of Squares of the given number
|P(n) = 1^2 + 2^2 + ... + n^2| |P(1) = 1| |P(2) = 1 + 4 = 5;| |P(3) = 5 + 9 = 14;| |P(4) = 14 + 16 = 30;|

10 years ago

Answered
Is it possible with for loop s1,s2,s3 variable looping ?
First see: * <http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F How can I create ...

10 years ago | 0

| accepted

Answered
array searching , copy and deleting
Problem: In Windows the name of a file may contain space (char(32)). %% str = 'name with space.txt this is a sample fi...

10 years ago | 0

Answered
is there a way to allow the user to input a string of numbers and then have the software pull specific numbers from it?
This is one way >> this=[183849384] this = 183849384 >> str = sprintf('%d',this) str = 183849384 >> nu...

10 years ago | 0

Answered
How to read specific lines from a text file and store them in an array?
Try >> out = cssm out = [1x104 char] [1x104 char] [1x104 char] [1x104 char] [1x104 char] [1x104 c...

10 years ago | 0

Answered
variable index to many matrices
The answer is <http://se.mathworks.com/help/matlab/cell-arrays.html Cell Array> B{1}=[1 2;3 4]; B{2}=[7 8 9;4 5 6];

10 years ago | 0

| accepted

Answered
How to use workspace variables in functions
Use *|importdata|* as a function, see &nbsp <http://se.mathworks.com/help/matlab/ref/importdata.html *|A = importdata(filename)|...

10 years ago | 1

| accepted

Answered
How to delete rows from a matrix when the values of certain columns are equal?
Try >> M = [1 1 7 8; 2 3 6 9; 5 8 10 8; 4 4 3 1] M = 1 1 7 8 2 3 6 9 5 ...

10 years ago | 0

| accepted

Answered
Loop to a specific point in data set
Why is *|fdValue|* a cell array in the first place? I assume the cell array contains a numerical scalar. If so replace ...

10 years ago | 0

| accepted

Answered
Read a specific number in a text file containing a mixture of strings and numbers
An alternative using regular expressions to parse one file %% tic str = fileread('MM1E1I1.txt'); xpr_num = [ ...

10 years ago | 1

Answered
I worked on nested loop.
Assuming that your goal is to understand loops, try this >> [ a01, a02 ] = cssm(); >> all(a01(:)==a02(:)) ans = ...

10 years ago | 0

| accepted

Answered
Reading multiple text files
Try *|cssm()|* it outputs to the screen 01/01/2013 0.0 01/02/2013 0.0 ... 02/27/2013 14.6 02/28/2...

10 years ago | 0

Answered
Make all elements of given row numbers equal to NaN.
I guess this is more efficient, and I think it's more readable %% B = A; is_nan_row = any( isnan( A ), 2 ); is...

10 years ago | 1

| accepted

Answered
hdf5 file read problem.
I would call this a practical joke. There is *a leading space* in the names of the datasets. (Caveat: This is the first time I e...

10 years ago | 1

| accepted

Answered
How can i remove a previous character present before the underscore including the underscore also.
Replace any one character followed by one underscore with empty string >> regexprep( 'my_john_sam', '._', '' ) ...

10 years ago | 0

Answered
Read data from a tricky text file
*Assuming _"data in the parentheses"_ all have equal length.* Why cell array? Isn't this good enough? %% fid = fopen( 'c...

10 years ago | 1

| accepted

Answered
How to output a random element from a vector in matlab?
One way >> cssm(1:10) ans = 2 >> cssm([3,6,9,12,1,2]) ans = 3 >> cssm(1:10) ans = 6 ...

10 years ago | 0

Answered
how to search for multiple words anywhere in the sentence ?
Try this %% sentence_1 = 'abc battery def power ghi failure'; typo_str_1 = 'abc battery def power ghi faiXure';...

10 years ago | 0

Answered
Output for visdiff?
_"What needs to be compared is the file name"_ Try this main = dir( mainPath ); user = dir( choosenFolder ); ...

10 years ago | 0

| accepted

Answered
Read nonrectangle csv with brackets
I think reading and parsing must be done in two steps. With R2013a >> tic, C = cssm( 'cssm.csv' ), toc C = [11x...

10 years ago | 0

| accepted

Answered
Import hdf5 file into Matlab
I recommend * Run some of the examples, which comes with the Matlab documentation. * Use <https://www.hdfgroup.org/products/...

10 years ago | 0

| accepted

Answered
Very new to Matlab probably an easy answer for you guys.
Try this >> t = 1:4; >> v = -2*(exp(-2*t)).*cos(2*pi*10*t) - 20*pi*sin(2*pi*10*t).*exp(-2*t) v = -0.2707 -0.0...

10 years ago | 0

Answered
Vectorization of 3 nested for loops.
I don't think that your code can be vectorized. However, this should be a bit faster for nset=1:100 for nindy=1:5 ...

10 years ago | 0

| accepted

Answered
Search within a structure using a string
Try >> S.a.b.c = 'abc'; >> S.('a').('b').c ans = abc and str = Clicks.( sprintf('prof_%u',p) ).( sprintf('...

10 years ago | 0

Answered
Opening csv file using textscan returns [0x1 double]
A bit of googling in combination with trial and error >> cac = cssm('090315_D1_20BSA-3.csv') Warning: The encoding 'UTF-...

10 years ago | 1

Answered
help with nested indexing
One way [~,ixb] = ismember( Nzlocs, locs ) ixb = 1 7 9 14 25 and a way using *|arrayfun|* and *...

10 years ago | 0

| accepted

Answered
How to keep only positive values in an array?
Given 1D-array, i.e a vector >> A = [ -18 -13 0 8 51 133 255] A = -18 -13 0 8 51 133 255 >> B ...

10 years ago | 17

| accepted

Answered
Export matched lines from two text files
Here is an example of a different approach to solve the task. The two output files, *|mwithrm21_reduced.txt|* and *|matches.txt|...

10 years ago | 2

Answered
Creating vector only containing odd values
Try >> x = [1 2 3 4 5]; >> x(rem(x,2)==0) = x(rem(x,2)==0)-1 x = 1 1 3 3 5 or rather ...

10 years ago | 0

Load more