Respondida
how to convert cell to matrix ?
A = cell2mat(cellfun(@str2num,x,'UniformOutput',false))

más de 3 años hace | 1

Respondida
Possible to modify only one portion of an array in one line?
x(x > xMax & 1:length(x) > transition) = xMax

más de 3 años hace | 2

Respondida
How to compare the closest value in the matrix?
% your data unknownM = [0.8105 1.1581 0.6295 0.9594 0.8447 0.7103 0.8429 0.5372 0.9882 0.8924]; sud...

más de 3 años hace | 0

Respondida
how can I create a 4D matrix and use it for interpolation
% your vectors Wpig=0.5:0.5:7; Chla=0.5:0.01:0.6; Starch=0:0.04:0.24; Now you need to sample uniformly the space using your...

más de 3 años hace | 0

Respondida
How can i break down the values of vector into group of five?
If x is your vector you can reshape it y = reshape(x,5,numel(x)/5); and access each column with indexing % column 10 iCol = ...

más de 3 años hace | 0

Respondida
index in position 2 exceeds array bounds ( must not exceed 1).
Difficult to say without file, code, etc. The wizard says that the new excel file has only one column, but the code expects tw...

más de 3 años hace | 0

Respondida
if statement in for loop with cell arrays
To stick with the OP snippet I added semicolons all over the place I changed the variable type in s.score to doubles I preall...

más de 3 años hace | 0

Respondida
How to create an array and fill it by these values using loop ?
% intialization and preallocation k = 1; date = strings(480,1); % string array for i = 1982:2015 for j = 1:12 ...

más de 3 años hace | 1

Respondida
Monte Carlo integration of sin(x)
This code evaluates the integral using the Monte Carlo method with increasing number of random samples, compare the result with ...

más de 3 años hace | 0

Respondida
Check if a number is in between two values
% your data a = [1,2,3,4,5,6]' b = [10,11,12,13,14,15]' Interval = [a b]; % number to check x = 8; % this finds the in...

más de 3 años hace | 2

Respondida
Assembling Element Matrices in Finite Element Method Problem
If I have understood correctly, you want to store the local 3x3 matrix in the global matrix. To do so you can (I would say must)...

más de 3 años hace | 1

Respondida
How to find corresponding row positions of specific values in a matrix?
The function min will do this for you [B,C] = min(A,[],1);

más de 3 años hace | 0

Respondida
How to convert script from fortran90 to matlab language
Again, it is difficult to check if not all code is available, however I try kB = zeros(10,1); kA = zeros(10,1); kL = 0; kS =...

más de 3 años hace | 1

Respondida
Pad with Nan according to maximum row in cell
I keep all steps separated % the data A = {rand(47,1),rand(80,1),rand(97,1)}; % pad with NaNs A = cellfun(@(x)[x(1:end); N...

más de 3 años hace | 1

Respondida
Keeping Previous Iteration changes
I see two problems in your code 1) the changes are only temporarily saved in x and x is never used 2) onec you change a letter...

más de 3 años hace | 0

Respondida
How to get rid of Nan when calculating mean
Following Steven Lord answer I would usE mean(A(isfinite(A)))

más de 3 años hace | 1

Respondida
Why is my script not working?
I try 1) I think you are caluclating the jacobian matrix. To avoid mistakes I did this symbolically and the result is >> syms...

más de 3 años hace | 0

Respondida
Parallelogram rule for vectors
Vtot = V1+V2+V3+V4

más de 3 años hace | 0

Respondida
Extract values from image
I assume you have X,Y and B as created using meshgrid, and the line is specified by start/end node % create dummy data x = lin...

más de 3 años hace | 0

Respondida
Help with nested for loop generating coordinates
The command you are looking for is meshgrid % vectors with positions x = 0.00470:.0003:.0071; y = 0.00470; z = 0:0.00005:.00...

más de 3 años hace | 0

Respondida
Is there a way of removing these for loops to speed up my code?
Profiling your code it comes up that the most demanding routine is the Green function calculation, with 0.374s: I have rewrit...

más de 3 años hace | 0

Respondida
Fit data to sawtooth shape
As usual, John is right. I tried to implement a strategy to fit sampled data with noise with a sawtooth waveform. I am pretty pr...

más de 3 años hace | 0

Respondida
Find position of a column given a specified array
idx = find(ismember([Mritsum(:) BrB(:)],point,'rows'))

más de 3 años hace | 0

Respondida
How do i plot a 3D structure as in the attached picture?
I share with you a couple of function that I use to plot grounding grids. They are attached. Then you can use the following scri...

más de 3 años hace | 0

Respondida
How to assign to an already 3d surface a colormap based on a set of values ?
Not sure if I have understood correctly. I try. I assume that you have the temperature plot as 2d matrix, as required by surf, b...

más de 3 años hace | 1

Respondida
How can I plot this function
You may use surf % define a suitable number of x and y divisions. Here I used 200 x = linspace(0,10,200); y = linspace(1,30,2...

más de 3 años hace | 0

Respondida
How can I extract a signal between zero up-crossings
You can take a look at this post, where zero crossing is discussed in details https://it.mathworks.com/matlabcentral/answers/26...

más de 3 años hace | 0

Respondida
Unique ID Min and Max with multiple values per Unique ID
Tessa, look if this fits your problem % col vector M1 = [10 17 201 333 1000].'; M2 = [10 10 17 17 17 201 1000; 0.1 69 1.7 33...

más de 3 años hace | 0

Respondida
split dataset with probability weights
datasample has a two outputs, where the second is the index to the selected data in your npop1. So: [rw1,idSelected] = datasamp...

más de 3 años hace | 0