Respondida
I need an example of a defined function in M-files
# From the command line, type this: edit # Copy the code below. # Paste it into the blank window that opened from step 1. ...

más de 13 años hace | 1

Respondida
Error: Function definitions are not permitted at the prompt or in scripts.
Don't try to define a function at the prompt or in a script. Put functions in their own M-files.

más de 13 años hace | 1

| aceptada

Respondida
Plotting velocity of a piston
You probably wanted element-by-element division rather than array division... y=29.688*(sin(0+b))./(sin(90-b)); % Note ./ ...

más de 13 años hace | 1

| aceptada

Pregunta


Counting occurrences in order
I am wondering if anyone knows of a toolbox function that can perform this task quickly. I am not familiar with the Stats toolb...

más de 13 años hace | 2 respuestas | 4

2

respuestas

Respondida
How to find duplicate values and what are they duplicates of?
There are many ways to do it. Here is another, just for fun: X = [2;5;1;2;2;0;0]; Y = arrayfun(@(x) {x find(X==x)},uniq...

más de 13 años hace | 0

Respondida
Is there a limit to the number of characters used in a symbolic expression?
This works. str = ['y ', sprintf('+ %i',1:6000)]; syms y,y=1; subs(str) length(str) % >1300 *Fixed a typo.....

más de 13 años hace | 0

| aceptada

Respondida
Use eval statement to create Matrices with variables
Why are you using EVAL in the first place? This is usually *strongly* discouraged because it is *slow*, it is *prone to bugs* a...

más de 13 años hace | 3

Respondida
replacing a string with another and vice versa
str = 'log(a(2))+a(3)*cosh(exp(bb(5)))'; % Initial string str = regexprep(str,'(bb)\((\d)\)|(a)\((\d)\)','$1_$2')

más de 13 años hace | 0

| aceptada

Respondida
Finding the roots of a function gotten from using ODE45
You can do it fairly painlessly. Here is an example of finding the zeros of the solution to the Van der Pol equation with mu=2:...

más de 13 años hace | 0

Respondida
Calculating input matrix to Upper triangular matrix
A = magic(5); [m,n] = size(A) You might want to look at the TRIU function.

más de 13 años hace | 1

| aceptada

Respondida
How to assign a vector data to a structure array?
When you do this: y(1:length(x)).real = deal(x{:}) MATLAB only sees one output argument, but numel(x) input arguments. ...

más de 13 años hace | 0

Respondida
I want to solve a sinus equation.
x = asin(b*sin(c)/d) Or, if you want MATLAB to do it: solve('b*sin(c)-d*sin(x)','x') You want x to be on [0 pi]? Y...

más de 13 años hace | 0

Respondida
Question about strings on a matrix.
It looks like you have a cell array of strings. The single quotes only appear when the array displays; they are not part of the...

más de 13 años hace | 0

| aceptada

Respondida
excell logarithmic trend formula equivalent in matlab
x = 1:.1:10; y = 3 + 4.5 * log(x); polyfit(log(x),(y),1)

más de 13 años hace | 0

Respondida
the code problem
Use the CONTINUE statement. k = 1; for ii = 1:10 for jj = 1:6 if(ii ==10 && jj == 3) con...

más de 13 años hace | 1

| aceptada

Respondida
Is there a way to obtain desired index without using 'find'?
ar=[102 243 453 768 897 243 653 23]; KEY = 1:length(ar); KEY(ar==243)

más de 13 años hace | 4

Respondida
Issues with GUI not running properly
Yes, guide GUIs need to have the initialization code in the M-file run before the figure will work as you want. It is the natur...

más de 13 años hace | 1

Respondida
detecting the existence of alphabetical elements
Perhaps best of all: str = 'adsf2342adsfwerreoj9f3f'; str2 = '23423'; flag = any(isletter(str)) flag = any(islet...

más de 13 años hace | 1

| aceptada

Respondida
structure indices in one line
V = values(urlAuthsMap,KH); % KH is the key you want. See key. From the link you showed above .... ;-)

más de 13 años hace | 0

| aceptada

Respondida
detecting the existence of alphabetical elements
str = 'adsf2342adsfwerreoj9f3f'; str2 = '23423'; flag = ~isempty(regexp(str,'[A-Za-z]')) flag = ~isempty(regexp(str2,...

más de 13 años hace | 0

Respondida
Gui interface code question.
What you need to remember is that you are getting a string, not a number. If you want to use it as a number, you must convert f...

más de 13 años hace | 1

| aceptada

Respondida
How can I change the fontface of a text within a plot
get(gca,'fontname') % shows you what you are using. set(gca,'fontname','times') % Set it to times

más de 13 años hace | 9

Respondida
GUI Question: Is it possible to print a symbolic expression on a GUI I created?
Yes, simply use the CHAR function on the output. Then set the string property of the uicontrol to the return of the call to CHA...

más de 13 años hace | 2

| aceptada

Respondida
I have no idea how to do this
You were very close, actually. A couple of things. One is, Sum holds your sum, so don't treat it like a vector by indexing int...

más de 13 años hace | 0

| aceptada

Respondida
matlab does not simplify the expression?
syms x simplify((x^10)^(1/5),'IgnoreAnalyticConstraints',true)

más de 13 años hace | 0

Respondida
Writing characters to empty matrix
You may want to use cell arrays. for ii = 30:-1:1 T{ii} = sprintf('abc_x_%i',ii); end Now look: T{25} Th...

más de 13 años hace | 0

| aceptada

Respondida
How do you convert an array into a square matrix?
Another: x = 1:10; % Original x = x(ones(1,length(x)),:) % indexing instead of repmatting.

más de 13 años hace | 0

Respondida
Efficient allocation of random numbers(U(0,1)) into categories
How about the <http://www.mathworks.com/help/matlab/ref/histc.html HISTC> function? Also, in your code there is no reference ...

más de 13 años hace | 0

| aceptada

Respondida
Question about arrays to elements.
I think the question is a little unclear, so I will go in a circle: A = [2 3 4 5 6] % Start here A2 = str2double(sprin...

más de 13 años hace | 0

Respondida
Plot curves with different colors inside the for loop and calculation of integral with trapz
Use: hold all instead of: hold on And don't tell MATLAB to make every curve blue! You are telling MATLAB to mak...

más de 13 años hace | 0

| aceptada

Cargar más