Answered
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")...

9 years ago | 0

Answered
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...

9 years ago | 0

| accepted

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

9 years ago | 0

| accepted

Answered
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...

9 years ago | 0

Answered
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...

9 years ago | 1

| accepted

Answered
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...

9 years ago | 0

Answered
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...

9 years ago | 1

| accepted

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

9 years ago | 3

| accepted

Answered
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...

9 years ago | 1

Answered
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...

9 years ago | 0

| accepted

Answered
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))...

9 years ago | 1

Answered
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...

9 years ago | 2

Answered
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...

9 years ago | 1

Answered
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...

9 years ago | 0

Answered
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})]; ...

9 years ago | 2

Answered
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...

9 years ago | 1

Answered
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 ...

9 years ago | 2

| accepted

Answered
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...

9 years ago | 0

Answered
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...

9 years ago | 0

| accepted

Answered
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 ...

9 years ago | 1

| accepted

Answered
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...

9 years ago | 0

Answered
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 ...

9 years ago | 0

| accepted

Answered
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...

9 years ago | 0

Answered
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...

9 years ago | 0

| accepted

Answered
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...

9 years ago | 4

| accepted

Answered
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...

9 years ago | 0

| accepted

Answered
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...

9 years ago | 0

| accepted

Answered
Index Exceeds Matrix on Runge Kutta Method
I took your code and made some changes to get it to run and produce a plot. Changes are noted in comments: % Define Param...

9 years ago | 0

| accepted

Answered
given f(x) and h, how to I calculate f(x+h)
E.g., using an anonymous function: >> f = @(x) x^4 f = @(x)x^4 >> h = 0.1 h = 0.1000 >> x = 5 ...

9 years ago | 0

Answered
"Index exceeds matrix dimensions" error in For Loop
You've got these two lines that define t differently: t = -T/7:0.001:T/7; syms t What is your actual intent for t? T...

9 years ago | 0

Load more