Risposto

How to replace a for loop with something faster

Hi! If you don't need the results of every loop, you can write: p1 = phi.*r; p2 = phi.*(lam_+g_)-.5*g_^2; p3 = .5....

How to replace a for loop with something faster

Hi! If you don't need the results of every loop, you can write: p1 = phi.*r; p2 = phi.*(lam_+g_)-.5*g_^2; p3 = .5....

oltre 10 anni fa | 0

Risposto

How can I separate complex data from a .txt file?

Hi! It seems all your 6 fields in a row are separated with ",", right? The easiest is to read in the whole file and process e...

How can I separate complex data from a .txt file?

Hi! It seems all your 6 fields in a row are separated with ",", right? The easiest is to read in the whole file and process e...

oltre 10 anni fa | 0

| accettato

Risposto

Problem using regexp to extract certain lines

Hi! I would suggest another approach. It is (in my opinion) easier to debug, because you can track your steps easily. % ...

Problem using regexp to extract certain lines

Hi! I would suggest another approach. It is (in my opinion) easier to debug, because you can track your steps easily. % ...

oltre 10 anni fa | 0

| accettato

Risposto

How many workspaces are present in matlab??

Hi! Each function has its own workspace. If you write a function you will have a separate workspace to work in, without the v...

How many workspaces are present in matlab??

Hi! Each function has its own workspace. If you write a function you will have a separate workspace to work in, without the v...

oltre 10 anni fa | 1

Risposto

How to use/skip multiple strings in a legend

Hi! Did you read this page? <http://www.mathworks.com/help/matlab/creating_plots/controlling-legends.html Controlling Legends...

How to use/skip multiple strings in a legend

Hi! Did you read this page? <http://www.mathworks.com/help/matlab/creating_plots/controlling-legends.html Controlling Legends...

oltre 10 anni fa | 0

Risposto

Matlab (R2012b) on windows 7 closing itself while running scripts

Hi! In your scripts do you use "exit"? This terminates matlab. If you only want to _exit_ a matlab script or function you nee...

Matlab (R2012b) on windows 7 closing itself while running scripts

Hi! In your scripts do you use "exit"? This terminates matlab. If you only want to _exit_ a matlab script or function you nee...

oltre 10 anni fa | 0

Risposto

Regular expressions, words in a pattern

Hi! "\w" does not match spaces!

Regular expressions, words in a pattern

Hi! "\w" does not match spaces!

oltre 10 anni fa | 0

Risposto

How can I generate a matrix?

Hi! Loop over your a/b vectors and increase the specified matrix element: M = zeros(max(a), max(b)); for n = 1:le...

How can I generate a matrix?

Hi! Loop over your a/b vectors and increase the specified matrix element: M = zeros(max(a), max(b)); for n = 1:le...

oltre 10 anni fa | 1

| accettato

Risposto

simulation for an array

Hi! As far as I understand you want to create a movie? You can plot to a figure, capture the figure and play the movie like t...

simulation for an array

Hi! As far as I understand you want to create a movie? You can plot to a figure, capture the figure and play the movie like t...

oltre 10 anni fa | 0

Risposto

How to read a txt file containing letters and number

Hi! You can read in with textscan as strings and convert afterwards: % read file fid = fopen('plante1_no_head.txt'); ...

How to read a txt file containing letters and number

Hi! You can read in with textscan as strings and convert afterwards: % read file fid = fopen('plante1_no_head.txt'); ...

oltre 10 anni fa | 0

Risposto

How to prevent function output being overwritten in for loop?

Hi! Use arrays to save the results: % allocate arrays for results Energyin = zeros(JN-1, 1); Energyout= zeros(JN-1...

How to prevent function output being overwritten in for loop?

Hi! Use arrays to save the results: % allocate arrays for results Energyin = zeros(JN-1, 1); Energyout= zeros(JN-1...

oltre 10 anni fa | 0

| accettato

Risposto

Failure in look-up table / failure in my matlab

Hi! The help uses sfix(8) instead of ufix(8) and another scaling: <http://www.mathworks.com/help/simulink/slref/fixpt_interp1...

Failure in look-up table / failure in my matlab

Hi! The help uses sfix(8) instead of ufix(8) and another scaling: <http://www.mathworks.com/help/simulink/slref/fixpt_interp1...

oltre 10 anni fa | 0

| accettato

Risposto

How can i use threshold to convert a gray-scaled image into binary image ?

Hi! If you load an image into matlab, you get a matrix A (for example) of size (XxYx3) with X and Y being the number of pixel...

How can i use threshold to convert a gray-scaled image into binary image ?

Hi! If you load an image into matlab, you get a matrix A (for example) of size (XxYx3) with X and Y being the number of pixel...

oltre 10 anni fa | 2

Risposto

Error using * Inner matrix dimensions must agree. HELP

Hi! My guess: You write T1 = mult * cos(kRca); If mult and kRca have the same length and you want to multiply elemen...

Error using * Inner matrix dimensions must agree. HELP

Hi! My guess: You write T1 = mult * cos(kRca); If mult and kRca have the same length and you want to multiply elemen...

oltre 10 anni fa | 0

Risposto

Finding Indices of Duplicate Values

Hi! You may use "unique". The second output is the index of all unique values, e.g. in column 3. All other indices are duplic...

Finding Indices of Duplicate Values

Hi! You may use "unique". The second output is the index of all unique values, e.g. in column 3. All other indices are duplic...

oltre 10 anni fa | 6

| accettato

Risposto

Question about a script

Hi! You may not mix a script with a function in one file! If you want to write a function called "pos_vel", you have to save ...

Question about a script

Hi! You may not mix a script with a function in one file! If you want to write a function called "pos_vel", you have to save ...

oltre 10 anni fa | 0

Risposto

Multiplying a changing amount matrices.

Hi! I'm not sure if I understood correctly. You can concat N matrices into a 3d matrix with dimensions (2x2xN). Basically, yo...

Multiplying a changing amount matrices.

Hi! I'm not sure if I understood correctly. You can concat N matrices into a 3d matrix with dimensions (2x2xN). Basically, yo...

oltre 10 anni fa | 1

Risposto

How to change a matrix as inserting zeroes both end sides?

Hi! Use diag: <http://www.mathworks.com/help/matlab/ref/diag.html?searchHighlight=diag>

How to change a matrix as inserting zeroes both end sides?

Hi! Use diag: <http://www.mathworks.com/help/matlab/ref/diag.html?searchHighlight=diag>

oltre 10 anni fa | 0

Risposto

How can I plot coordinates with different colours based on the value and family of my variables ?

Hi! X = [2 4 -3 5 6]; Y = [4 9 1 -2 1]; L1 = [1 1 1 1 1]; L2 = [2 1 2 1 2]; L3 = [3 3 3 3 1]; L4 = [10 0...

How can I plot coordinates with different colours based on the value and family of my variables ?

Hi! X = [2 4 -3 5 6]; Y = [4 9 1 -2 1]; L1 = [1 1 1 1 1]; L2 = [2 1 2 1 2]; L3 = [3 3 3 3 1]; L4 = [10 0...

oltre 10 anni fa | 0

| accettato

Risposto

How can I generate a sample of 1-D random numbers following Gaussian distribution

Hi! It seems you already found your solution on file exchange. Why don't you use it? Your input function will be m=0;...

How can I generate a sample of 1-D random numbers following Gaussian distribution

Hi! It seems you already found your solution on file exchange. Why don't you use it? Your input function will be m=0;...

oltre 10 anni fa | 0

| accettato

Risposto

comparing matrix elements and performing operation if equal

Hi! % get indices of unique values [~, ~, c] = unique(A(:, 1)); % loop over all unique values for n = 1:max...

comparing matrix elements and performing operation if equal

Hi! % get indices of unique values [~, ~, c] = unique(A(:, 1)); % loop over all unique values for n = 1:max...

oltre 10 anni fa | 0

| accettato

Risposto

How to order values within a cell array more efficiently??

Hi! orderedratings = cellfun(@(x) ratings{3,x}, ... cellfun(@(x) strcmp(x,ratings(2,:)), ratings(1,:), 'UniformOut...

How to order values within a cell array more efficiently??

Hi! orderedratings = cellfun(@(x) ratings{3,x}, ... cellfun(@(x) strcmp(x,ratings(2,:)), ratings(1,:), 'UniformOut...

oltre 10 anni fa | 1

Risposto

Function/method to truncate the fractional part of a number in Matlab

Hi! To get the fractional part you may use fractionalpart = x - floor(x) Try it with "x=pi" for example. And try it ...

Function/method to truncate the fractional part of a number in Matlab

Hi! To get the fractional part you may use fractionalpart = x - floor(x) Try it with "x=pi" for example. And try it ...

oltre 10 anni fa | 0

Risposto

Printing specific lines to a text file

Hi! If you read line by line with textscan, you should use '\n' as delimiter. fid = fopen(FileName, 'r'); FC = textsc...

Printing specific lines to a text file

Hi! If you read line by line with textscan, you should use '\n' as delimiter. fid = fopen(FileName, 'r'); FC = textsc...

oltre 10 anni fa | 0

Risposto

How to read large data file in Matlab?

Hi! Is it a binary file or a normal text file? For text files you may use "fopen" and "fgetl" to read line by line. If you kn...

How to read large data file in Matlab?

Hi! Is it a binary file or a normal text file? For text files you may use "fopen" and "fgetl" to read line by line. If you kn...

oltre 10 anni fa | 0

| accettato

Risposto

Help with csv data preparation

Hi! In your cell array the second and third entry of every line are numeric values already. You may split the string in the f...

Help with csv data preparation

Hi! In your cell array the second and third entry of every line are numeric values already. You may split the string in the f...

oltre 10 anni fa | 0

| accettato

Risposto

How can I delete certain rows of a matrix based on specific column values?

Hi! Suppose you have matrix M: % logical vector for rows to delete deleterow = false(size(M, 1), 1); % loop ov...

How can I delete certain rows of a matrix based on specific column values?

Hi! Suppose you have matrix M: % logical vector for rows to delete deleterow = false(size(M, 1), 1); % loop ov...

oltre 10 anni fa | 0

Risposto

Help in importing csv file

Hi! You may just load your file and process it afterwards like % load file fid = fopen('data.csv', 'r'); FC = ...

Help in importing csv file

Hi! You may just load your file and process it afterwards like % load file fid = fopen('data.csv', 'r'); FC = ...

oltre 10 anni fa | 0

| accettato

Risposto

Printing to specific lines in a text file

Hi! It is not difficult if the same columns are text and numbers. You can simply loop over all data and printf with "fprintf"...

Printing to specific lines in a text file

Hi! It is not difficult if the same columns are text and numbers. You can simply loop over all data and printf with "fprintf"...

oltre 10 anni fa | 0