0
votes
1answer
16 views

Insert matrix element into a Function input in Matlab

I want to make a function that can take a matrix element as an input. Is this possible? I have in the main script a matrix like: A = [0 1 2 3 4 5 6 7 8] I want to make a function that is like: ...
-1
votes
3answers
36 views

MatLab error: Too many input arguments

I have defined a function like this: function [phi_D,phi_S,v_S] =libem2(n_D,p_D,n_S,vertpts_S,elemvert_S,alpha_S,beta_S,f_S) Clearly libem2 takes in 8 arguments. This function is actually a helper ...
1
vote
1answer
26 views

Issue Changing Script to function in MatLab

I am trying to give a/set 'rho_real' to this code and receive P_Mpa as an/set of outputs, however the initial 'rho_real' does not seem to get changed as I run the function. Any Help is greatly ...
2
votes
2answers
39 views

Function returns vector instead of scalar [closed]

I have defined two anonymous functions like this: hx = @(x) 0.23.*(x>=a).*(x<5) + ... 2.8020.*exp(-x/2).*(x>=5).*(x<=b); Hx = @(x) p.*c.*x.*(x>=0).*(x<5) + ... ...
0
votes
2answers
40 views

Functions and function name errors

I'm trying to write a simple function, e.g: function [x y] = functionname (a, b, c, d, e) so I create an m-file called function-name.m, with all the variables specified. However, the m-file from ...
2
votes
3answers
45 views

Matlab: passing functions as arguments of a function

The function that I want to build is: function y = myfunction(data, @f1, @f2, @f3, @f4) %Fit data using f1,f2,f3,f4 such that data ~ af1+bf2+cf3+df4 end where data is an array. The user will define ...
0
votes
2answers
45 views

I used while loop and my project become not responding (MATLAB)

I'm beginner in MATLAB programming. I'm working on statistic data and I have some problem with while looping. Here's the codes : % --- Executes on button press in b_analisa_data. function ...
0
votes
1answer
18 views

Matlab: Plot a function with different parameters into

In Matlab I have a function calling a set of parameters. I have 3 sets, and I can call them individually and plot them.. No problems there. But I want to be able to compare them in one single plot. ...
1
vote
2answers
33 views

Memory size of function handle - MATLAB

One of the fields in my structure is a function handle: strct.handl=@(arg1,arg2)handl(arg1,arg2,par1,par2) Now, arg1 and arg2 are defined every time I use the handle, but par1 and par2 are stored ...
7
votes
3answers
107 views

Why is the Matlab function “feval” needed?

A function handle can be used to call a function, e.g. f = @sin; val = f(1.0); so why is "feval" ever needed? val = feval(f, 1.0); When is it useful?
1
vote
3answers
27 views

Matlab Callback Function Only Sees one Parameter Passed to it

I'm writing my first GUI programmatically in Matlab. I have built the visual aspect of the GUI and I am now in the process of writing the Callback functions. When I write the callback function I need ...
1
vote
3answers
54 views

How to evaluate a function at a point in Matlab?

For example, if I have a function f(x)=x^2, how can I evaluate it at x=2? I have tried employing the symbolic toolbox and using the following code in the Command Window: syms x; f = sym(x^2); ...
0
votes
2answers
27 views

Matlab arrayfun mapping using two arrays?

How would I go about mapping the values of TWO arrays to a function and returning the result as an array? arr = [1, 2, 3]; arr2 = [1, 4, 5]; val= arrayfun(@(x) func(arr, arr2)) function val = ...
0
votes
2answers
41 views

how to find min and max of float number in matlab

The min and max functions in MATLAB work on only integer values. How can I find the min and max of a double vector? a = [2.1 3.4 5.6 7.6] min(a) returns to me: Subscript indices must either be ...
1
vote
0answers
32 views

Incorporating Structure Fields into a Function as Inputs (in MATLAB)

I'm using MATLAB (Mapping Toolbox) to create a large number of lines between different countries. Since there are so many lines, I'm trying to do this using object-oriented programming. This is the ...

1 2 3 4 5 24
15 30 50 per page