Respondida
How to construct a customized outer function for 2 vectors?
Start with a vectorized function handle, e.g., f = @(x,y)x.^y Then use bsxfun, e.g., result = bsxfun(f,A,B); Not...

casi 8 años hace | 0

| aceptada

Respondida
How to pass equation to a function where the function subplots graphs?
y_exact_overdamped is a function handle. You pass that into your function which gets it as y_exact. You then assign this to y1. ...

casi 8 años hace | 0

Respondida
ToFile from SImulink read into C++ standalone program
Time series objects are classdef OOP objects. To get at the underlying data in them, you will need to use the mxGetProperty API ...

casi 8 años hace | 0

Respondida
Storing a vector in a loop each time with a different name
This is not the best way to do this in MATLAB. There are many, many posts on this site explaining why. Instead, you should use c...

casi 8 años hace | 0

| aceptada

Respondida
Rearrange matrix into single row
result = reshape(b.',1,[]); The transpose is needed to get the row values to line up in memory first before doing the resha...

casi 8 años hace | 2

Respondida
Why do I have 2 outputs instead of 1
The comma in MATLAB is a separator (i.e. forms a "comma-separated-list"), not a decimal point. So typing in 0,1 is equivalent to...

casi 8 años hace | 0

Respondida
Is it possible to iteratively increase a number within the middle of a file name?
E.g., using sprintf n = some integer sprintf('Myfilename%dwith%dand%dstuff',n,n,n) Sample run: >> n = 5; >> s...

casi 8 años hace | 0

| aceptada

Respondida
Subroutine functions in MatLab
Create a file with the following name: init.m Put your code into this file, e.g., function stuff = init stuff = what...

casi 8 años hace | 0

Respondida
How to calculate argument max for a vector
Assuming "arg max" means index of the max location, use both outputs of the max function p = your vector [m,x] = max(p);...

casi 8 años hace | 0

| aceptada

Respondida
How to change values of elements in a sparse matrix
Not sure what your problem is. Sparse matrix elements can be changed directly just like full matrices. E.g., F = your full ...

casi 8 años hace | 1

| aceptada

Respondida
Largest value of x such that 2^(-x)>0
If you are talking about the numerical range of IEEE floating point numbers, then the answer depends on the specific bit formatt...

casi 8 años hace | 0

Respondida
Calculate weighted average of a 2D matrix
E.g., w = 1x481 vector of weights M = your 376x481 matrix of values result = sum(M.*w,2) / sum(w); or sum(bsx...

casi 8 años hace | 0

| aceptada

Respondida
Incorrect matrix computation: a*inv(a) does not produce the identity matrix
The "a" matrix you are using is not full rank and does not have an inverse. That is what the warning message is trying to alert ...

casi 8 años hace | 0

| aceptada

Respondida
MEX question: How to set scalar and array values within plhs[0] struct?
mxGetField returns a pointer to mxArray, not pointer to double. You need to get at the data with the appropriate function. E.g.,...

casi 8 años hace | 0

Respondida
Changing elements of an array by row and column using for loop?
You should probably be using size(alpha,1) and size(alpha,2) instead of length(alpha) and size(alpha) in your looping. And you n...

casi 8 años hace | 0

| aceptada

Respondida
how to use for loop for below.
This line function area = areaCircle(r) means the function input is r and the output is area. So you need to assign the ...

casi 8 años hace | 0

| aceptada

Respondida
Numerical instability of acos
Since you don't show us any code so that we can see where these "funny" values might be coming from, I can only point you to thi...

casi 8 años hace | 0

Respondida
How to separate M*3 matrix by interval of 1
E.g., maybe something like this? data = your 20x3 matrix x = data(:,1); result = data( 0<x & x<1 ,:);

casi 8 años hace | 1

Respondida
Initialize a field in all elements of a struct array
Another way using deal: [a(1:numel(a)).field2] = deal(4);

casi 8 años hace | 1

Respondida
Calculation of Factorial using Recursive Relation
You need the proper formula first: y = n * recursion(n-1); But also you need to figure out how to stop the recursion and...

casi 8 años hace | 0

| aceptada

Respondida
How to find value of x such that 2^(-x) =realmin
Just solve your equation directly: x = -log2(realmin) Note that realmin is for the smallest normalized number. Denormali...

casi 8 años hace | 2

Respondida
Problems with complex output in mex funtion
E.g., just using the definitions in the MATLAB doc: mxComplexInt16 *buf_prueba; : plhs[2] = mxCreateNume...

alrededor de 8 años hace | 0

Respondida
Finding a 3D parallel vector
A unit vector parallel to the points from (a,b,c) to (d,e,f) is just this: v1 = [a,b,c]; v2 = [d,e,f]; u = v2 - v1; ...

alrededor de 8 años hace | 2

| aceptada

Respondida
Obtain maximum value of variable over multiple iterations?
E.g., you could add a variable to your looping for this: altmax = -inf; % your loop start % stuff that calculates...

alrededor de 8 años hace | 0

| aceptada

Respondida
How to delete elements from a struct array?
Not exactly sure what you want to do. If you want to delete all structure elements (i.e., all fields for that element) where the...

alrededor de 8 años hace | 2

| aceptada

Respondida
Built in Julian Date Converter not working?
What version of MATLAB are you using? juliandate was introduced in R2014b. Are you using an unsupported class variable as one of...

alrededor de 8 años hace | 0

Respondida
I want to convert a 4x1 vector column to skew symmetric matrix in matlab
You could just use the code you have already typed above. E.g., a = Q(1); b = Q(2); c = Q(3); d = Q(4); S = [0 -a d ...

alrededor de 8 años hace | 0

| aceptada

Respondida
How to get a pointer to 2D array when writing a C source Mex file?
You can't use the [j][i] indexing syntax with the pointer returned by mxGetDoubles. You would need to set up a separate pointer ...

alrededor de 8 años hace | 1

| aceptada

Respondida
Adding a singleton dimension to a 2D vector
There is no way to force a variable to physically store trailing singleton dimensions past the 2nd dimension. Operations that na...

alrededor de 8 años hace | 2

Cargar más