Respondida
Cumulative sum of cell array column
result = cumsum(vertcat(A{:,7})); or result = sum(vertcat(A{:,7})); depending on what you want.

casi 10 años hace | 0

Respondida
round random a number
For purely random rounding regardless of the fractional part: x = your number result = round(floor(x)+rand);

casi 10 años hace | 2

| aceptada

Respondida
Found the answer. Thanks
Do you mean like this? [rows cols] = size(a); nDiags = rows + cols - 1; b=fliplr(a); x = zeros(min(rows,cols),nDia...

casi 10 años hace | 0

Respondida
Output Argument Error - How to Define The Output Argument for a Function
Don't have the return variable name the same as the function name. Use a different name for the return variable (e.g., "result")...

casi 10 años hace | 0

Respondida
Change Values of array to zero
The numbers are very small but not exactly 0. They just print as 0 with the display format used. To get them to exactly 0 you c...

casi 10 años hace | 0

| aceptada

Respondida
how to vectorize this loop
cumavg = cumsum(v)./(1:numel(v)); mark = find(cumavg<=(avg-0.01),1,'last');

casi 10 años hace | 0

| aceptada

Respondida
libcpmt.lib(xthrow.obj) : error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1800' in nms_gpu_mex.o
_MSC_VER is a value corresponding to the version of the Microsoft compiler that is being used. The 1600 is for Visual Studio 20...

casi 10 años hace | 0

Respondida
Assign values to different ranges of columns in rows in a 2Dmatrix
It is not entirely clear from your description what you want. If you want the entire column set to a certain value where the "i...

casi 10 años hace | 1

| aceptada

Respondida
Parse error at Function:usage might be invalid syntax
Very hard to read your pic of the code (in the future, post the actual code and not a picture), but from the looks of it you hav...

casi 10 años hace | 0

Respondida
Matrix indexing problem, column-major
if X(xr,xc) < (xr*xc) % <-- changed X to X(xr,xc) A = [A;[xr,xc]]; % <-- changed [xr;xc] to [x...

casi 10 años hace | 1

| aceptada

Respondida
how to convert a matrix into one single column vector
B = reshape(A',[],1);

casi 10 años hace | 3

| aceptada

Respondida
Looping with two vectors ?
It is unclear why you have a loop at all, but maybe this is what you want? for ii = 3002:10001 Or maybe you just need to...

casi 10 años hace | 1

Respondida
Creating a matrix that calculates inverse and determinants without using the det and inv commands
Create a file in your working directory called invanddet2by2.m, e.g. edit invanddet2by2.m In that file, put the followin...

casi 10 años hace | 0

| aceptada

Respondida
Error using / Matrix dimensions must agree.
Use element-wise operators .* and ./ instead of matrix operators * and / y=abs(1/complex(0,2)*( 1./(1-exp(complex(0,-Ts*w))...

casi 10 años hace | 1

Respondida
Unable to compile using "mex fmpc_sim.c libmwblas.lib libmwlapack.lib" undefined reference to '_dgemm_'
Looks like the source code you are using was intended for UNIX machines. In particular these errors: c:\users\n\appdata\loc...

casi 10 años hace | 2

Respondida
Write a function that takes an input argument n, checks whether or not n is positive, and then provides the sum: 1 + √2/2! + √3/3! + ⋯ + √n/n!.
1) Create a function file called myfunction.m in your working directory. E.g., edit myfunction.m 2) Put the following co...

casi 10 años hace | 1

Respondida
Write a function that receives an input argument of a number of kilometers (km) and will output the conversions into both miles (mi) and US nautical miles (n.m.). Use the conversions: 1 km = 0.621 mi and 1 km = 0.540 n.m.
1) Create a function file called myconversion.m in your working directory. E.g., edit myconversion.m 2) Put the follow...

casi 10 años hace | 0

Respondida
How do I combine data from two structures?
E.g., with a loop using dynamic field names: f = fieldnames(A); for k=1:numel(f) A.(f{k}) = [A.(f{k});B.(f{k})]; ...

casi 10 años hace | 2

Respondida
Why is it saying that I am exceeding the matrix dimensions for the sum_xy when x(2) is clearly a part of the vector that I give
You want to change your while test to this: while i < n because the next line increments i. If you allow i to be n afte...

casi 10 años hace | 1

Respondida
Assign vectors (returned from a function) to the colums of a matrix
If you can modify the source code of myfun, you could have it detect the number of requested outputs. If the number is greater ...

casi 10 años hace | 2

| aceptada

Respondida
How do I assign a text to a numerical value for an array inside of a for loop?
If UPDRS1997 is just a scalar you could do this: conditions = {'normal','slight','mild','moderate','severe'}; x = condit...

casi 10 años hace | 0

Respondida
Why does Matlab transpose hdf5 data?
In the following link: <https://support.hdfgroup.org/HDF5/doc/H5.format.html#LayoutMessage> I read the following under Dat...

casi 10 años hace | 0

| aceptada

Respondida
WHILE loop with a condition on a vector?
Like this? while any(~(abs(vector_a) <= 0.00001)) % do stuff end Or this (but will not get the same result if ...

casi 10 años hace | 1

| aceptada

Respondida
load and if conditions
Maybe just get rid of that for-loop (assuming _pick_year_ is one of the variables that gets loaded). E.g., pick_year = inpu...

casi 10 años hace | 0

Respondida
For some reason every time I try to test my forward elimination function there is an error in the sum part, I cannot figure out why or what else I need to ad
Looks like you are incrementing the i index variable twice ... once as a for-loop index and once explicitly: for i = 1:n ...

casi 10 años hace | 0

| aceptada

Respondida
Why can't I mex cpp with matlab?
You should not redefine mwSize and mwIndex in your code ... you should only define them if they are not already defined. One wa...

casi 10 años hace | 0

Respondida
What is the final value of this variable when executed in MATLAB?
Just take each term that gets added to final_value in the for-loop and add up what happens for each iteration. E.g., the term th...

casi 10 años hace | 0

| aceptada

Respondida
difference in brackets (, [ or no brackets?
0:2:10 produces a row vector of the numbers 0,2,4,6,8,10. In the [0:2:10] and (0:2:10) versions, the [ ] and ( ) are simply r...

casi 10 años hace | 4

| aceptada

Respondida
Insert first value in vector into next 11 lines using an If loop
This follows your specified pattern using the repmat function: T = your 8754x1 temp data vector Tresult = reshape(repmat...

casi 10 años hace | 0

| aceptada

Respondida
How can I access a field in a structure array using a cell array containing strings corresponding to these fields using a for cycle?
You almost had the syntax correct. Use "dynamic field names" by enclosing the field name variable (in this case B{i}) inside pa...

casi 10 años hace | 0

| aceptada

Cargar más