problem with 'solve' function in matlab 2008 and upper
이전 댓글 표시
I have a function in matlab, I want to find its maximum.. ( my function is guassian signal, it has a 2 pulse, I want to find extermum point of each pulse and calculate distance between their extermum).
base on this data, I used this commands:
syms t
Z=[0.000001116863592 0.000004972731239 -0.547213084010968 1.015860491921958]
alpha = 1.749262265091693e+013
Fc = 4.334354827118762e+006
phase2 = 0.991124769614895
phase1 = -0.549482979269295
solve(diff((Z(4).*exp(-alpha.*(t-Z(2)).^2).*cos(2*pi.*Fc.*(t-Z(2))+phase2))))-solve(diff((Z(3).*exp(-alpha.*(t-Z(1)).^2).*cos(2*pi.*Fc.*(t-Z(1))+phase1))));
this commands work in Matlab 2007a, but dont work in upper version. What should I do?
댓글 수: 4
Walter Roberson
2011년 8월 24일
Please clarify what you mean by "don't work".
The values you give for z and alpha and so on: are those representing outputs or commands? If they represent commands, you should probably be using subs() instead.
fsalehi
2011년 8월 30일
Walter Roberson
2011년 8월 30일
You do not tell solve() what to solve for, and it is not going to be able to solve what you give if you give it in that order. You have to move the solve() command after the assignments. You should probably also use
tsol = solve(diff((Z(4).*exp(-alpha.*(t-Z(2)).^2).*cos(2*pi.*Fc.*(t-Z(2))+phase2))))-solve(diff((Z(3).*exp(-alpha.*(t-Z(1)).^2).*cos(2*pi.*Fc.*(t-Z(1))+phase1))), t);
to be sure that solve will solve for the variable t and return just that variable.
I am not certain at the moment why solve() is returning a 1x1 matrix. Try asking what the class() of the result is, and try asking what size() of it is. It might be a symbolic array of answers for which it happened to find only a single answer.
fsalehi
2011년 8월 31일
답변 (2개)
Kai Gehrs
2011년 8월 30일
0 개 추천
Hi,
I agree with Walter's recommendation. I just would like to add that the results returned by solve are SYM objects and scalar SYM objects (including numbers) are displayed as 1x1 SYM objects in the workspace/variable browser. Maybe this is the root cause for your question.
I run your example in R2011a and without checking the details it seems to work fine.
Best regarrds,
-- Kai
카테고리
도움말 센터 및 File Exchange에서 Mathematics에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!