Plotting help

Hi, I'm pretty new to Matlab, and I tried to execute this script:
eq1 = '((((1.5-(x-(i*(y))))/(1.5+(x-(i*(y)))))+((((x-(i*y))-((3.46163-(i*(0)))))/((x-(i*(y)))+(3.46163-(i*(0)))))*(exp(-2*i*((pi*2)/1796)*(x-(i*(y)))*z))))/(1+(((1.5-(x-(i*(y))))/(1.5+(x-(i*(y)))))*(((x-(i*(y)))-(3.46163-(i*(0))))/((x-(i*(y)))+(3.46163-(i*(0)))))*(exp(-2*i*((pi*2)/1796)*(x-(i*(y)))*z)))))-.30441';
eq2 = '((((1.5-(x-(i*(y))))/(1.5+(x-(i*(y)))))+((((x-(i*y))-((3.46153-(i*(0)))))/((x-(i*(y)))+(3.46153-(i*(0)))))*(exp(-2*i*((pi*2)/1798)*(x-(i*(y)))*z))))/(1+(((1.5-(x-(i*(y))))/(1.5+(x-(i*(y)))))*(((x-(i*(y)))-(3.46153-(i*(0))))/((x-(i*(y)))+(3.46153-(i*(0)))))*(exp(-2*i*((pi*2)/1798)*(x-(i*(y)))*z)))))-.30440';
eq3 = '((((1.5-(x-(i*(y))))/(1.5+(x-(i*(y)))))+((((x-(i*y))-((3.46143-(i*(0)))))/((x-(i*(y)))+(3.46143-(i*(0)))))*(exp(-2*i*((pi*2)/1800)*(x-(i*(y)))*z))))/(1+(((1.5-(x-(i*(y))))/(1.5+(x-(i*(y)))))*(((x-(i*(y)))-(3.46143-(i*(0))))/((x-(i*(y)))+(3.46143-(i*(0)))))*(exp(-2*i*((pi*2)/1800)*(x-(i*(y)))*z)))))-.30439';
ezplot(eq1), hold on;
ezplot(eq2), hold on;
ezplot(eq3), hold off;
but it didn't work (some of you want to sternly tell me off right now, I know). Here is the error message:
??? Error using ==> char
Cell elements must be character arrays.
Error in ==> ezplot at 158
fmsg = char(f);
Error in ==> nonlintest2 at 4
ezplot(eq1), hold on;
Error in ==> run at 74
evalin('caller',[script ';']);
So, as a new user, I don't know how to use this error report very well, and looking online has gotten me some approximate info, but nothing that truly explains my situation to me. Can anyone help me with this please? I'd love to learn how to make this work.

댓글 수: 2

the cyclist
the cyclist 2011년 9월 28일
Why did you enclose eq1, etc., in single quotes?
Fangjun Jiang
Fangjun Jiang 2011년 9월 28일
@cyclist, to use ezplot()

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2011년 9월 28일

1 개 추천

It is a bug in ezplot in constructing the error message to tell you that ezplot cannot be used to plot equations in more than 2 variables.

댓글 수: 8

Alex
Alex 2011년 9월 28일
Any solutions for that bug? What would you recommend that I do in this situation?
Walter Roberson
Walter Roberson 2011년 9월 28일
If you really wanted to, you could edit ezplot() so that you change line 158 to
if isa(f{1},'inline'); fmsg = char(f{1}); else fmsg = char(f); end
Of course all that will do is enable the program to reach the correct error() message; you would still need to adjust your program to try/catch to account for the possibility of that error.
Alex
Alex 2011년 9월 29일
So, as a new user, what does any of that mean?
Walter Roberson
Walter Roberson 2011년 9월 29일
It means that you should not use ezplot() to plot a function with three or more variables. Your equations all obviously involve x and y, and each of them has a single occurrence of z (which you can see near the beginning of the third text line of each, above.)
Perhaps you should double-check that you have not made an error in transcribing the equations: perhaps that z is intended to be x or y.
Alex
Alex 2011년 10월 1일
Well, I developed these equations myself, so I know that it's supposed to be "z". Z does not necessarily represent a direction either, it's just a placeholder value. I'm trying to solve simultaneous non-linear equations, and I wanted to use a graphical analysis to check answers, but neither of these things are working for me. Any suggestions?
Walter Roberson
Walter Roberson 2011년 10월 2일
You are expecting to be able to create a graphical representation of something that involves a symbolic constant? And over a complex field? You do realize that the graphs are non-linear in z, so it isn't even as simple as drawing a graph and adding a "multiplied by z" notation to it?
Perhaps it would make sense to substitute a specific value in for z before attempting the plot? You could do that with
eq1a = strrep(eq1,'z','1.234987');
and plotting that ?
Walter Roberson
Walter Roberson 2011년 10월 2일
Those equations are difficult to solve, even individually by substituting values in to free variables.
Alex
Alex 2011년 10월 3일
Yeah, that's the difficulty that I'm having with this. I don't know a lot about the language of Matlab, nor it's graphing capabilities, hence the post. If I had the optimization toolbox I could try using fsolve, but I don't, which leaves me in a pickle.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

질문:

2011년 9월 28일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by