index notation symbolic toolbox
Mostrar comentarios más antiguos
example: fi = sym('fi',[1 2]) fi =
[ fi1, fi2]
I want this to be: fi =
[ fi(1), fi(2)]
This in order to use outcome of symbolic manipulation directly in my matlab code.
4 comentarios
Dinant
el 5 de Nov. de 2013
Dinant
el 19 de Feb. de 2014
Sean de Wolski
el 20 de Feb. de 2014
Dinant, I answered your question and provided you with code that does exactly what you asked for. If it's not, please clarify in your comments what you actually want.
Dinant Kistemaker
el 19 de Feb. de 2019
Thanks for the help, but you did not. I have reinitiated my post in hope I can get a workaround for this...
Respuestas (6)
Sean de Wolski
el 4 de Nov. de 2013
>> fi = sym([1,2])
?
Dinant
el 4 de Nov. de 2013
0 votos
7 comentarios
Sean de Wolski
el 4 de Nov. de 2013
Is this what you're looking for?
Dinant
el 4 de Nov. de 2013
Sean de Wolski
el 4 de Nov. de 2013
Which can then be indexed like this:
fi(1)
fi(2)
Which is what you asked for.
Dinant
el 4 de Nov. de 2013
Sean de Wolski
el 4 de Nov. de 2013
Dinant, this is what my code does:
clear fi;
fi = sym([1 2]);
sin(fi(1))
It will not return two separate outputs because this is not how MATLAB works. Consider the same question for doubles:
[D(1) D(2)] = [1 2]; %error!
You would need to do this on two lines:
D(1) = 1;
D(2) = 2;
Knowing [1 2] upfront you would want
D = [1 2]
Then
D(1)
Dinant
el 4 de Nov. de 2013
Sean de Wolski
el 4 de Nov. de 2013
What release are you using? Because on mine(R2013b) it creates a 1x2 sym
Code:
fi = sym([1 2])
size(fi)
sin(fi(1))
Printed:
fi =
[ 1, 2]
ans =
1 2
ans =
sin(1)
Walter Roberson
el 4 de Nov. de 2013
syms fi
then fi(1) will be fi(1)
1 comentario
Dinant
el 4 de Nov. de 2013
Dinant Kistemaker
el 19 de Feb. de 2019
0 votos
I am still very much looking forward to an answer to my question. It is really annyoing that the printed format is not in vector notation. I want to use the output for some symbolic manipulations in my code and I want to use vector notation.
if I type:
fi = sym ('fi',[1 3]);
x=cos(fi)
>>x =
[ cos(fi1), cos(fi2), cos(fi3)]
I would very much want to have the answer in vector notation like:
x =
[ cos(fi(1)), cos(fi(2)), cos(fi(3))]
Dinant Kistemaker
el 26 de Feb. de 2019
0 votos
Nobody???
Dinant Kistemaker
el 26 de Feb. de 2020
0 votos
I am so looking forward to an answer to my problem...
Somebody from the Mathworks?
1 comentario
Steven Lord
el 26 de Feb. de 2020
If you want an official MathWorks answer please contact Technical Support directly using the telephone icon in the upper-right corner of this page.
I suspect you will not be able to do what you want with sym or syms. Depending on what "use outcome of symbolic manipulation directly in my matlab[sic] code" means the matlabFunction function may be of use.
Categorías
Más información sobre Code Performance en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!