I can't plot my function
Ältere Kommentare anzeigen
Here is my code:
syms y_rt;
Pp_Pr = 0.3;
alpha = 100;
x_rt = [0.1;0.01;1];
x_rt = y_rt * (1 + Pp_Pr * (1-y_rt) * (alpha - 1)) / (alpha - (alpha - 1) * y_rt)
figure
fplot(y_rt,x_rt,'r-');
I don't know what the problem is. Any help would be appreicated, this is the error message I keep getting:
Warning: The following error was caught while executing
'onCleanup' class destructor:
Index exceeds the number of array elements (1).
Error in sym>@()S.digits(oldDigits) (line 698)
resetDigits = onCleanup(@() S.digits(oldDigits));
Error in onCleanup/delete (line 81)
obj.task();
Error in sym/double (line 693)
if builtin('numel',S) ~= 1
Error in sym/unique (line 108)
indA = double(indA);
Error in countvars>symvarMulti (line 11)
vars = reshape(unique([vars{:}]),1,[]);
Error in countvars (line 5)
n = numel(symvarMulti(outer));
Error in fplot>singleFplot (line 236)
nvars = countvars(fn);
Error in
fplot>@(f1,f2)singleFplot(cax,{f1,f2},limits,extraOpts,args)
(line 208)
hObj = cellfun(@(f1,f2)
singleFplot(cax,{f1,f2},limits,extraOpts,args),fn{1},fn{2},'UniformOutput',false);
Error in fplot>vectorizeFplot (line 208)
hObj = cellfun(@(f1,f2)
singleFplot(cax,{f1,f2},limits,extraOpts,args),fn{1},fn{2},'UniformOutput',false);
Error in fplot (line 166)
hObj = vectorizeFplot(cax,fn,limits,extraOpts,args);
Error in task4plot (line 7)
fplot(y_rt,x_rt,'r-');
> In sym/double (line 693)
In sym/unique (line 108)
In countvars>symvarMulti (line 11)
In countvars (line 5)
In fplot>singleFplot (line 236)
In fplot>@(f1,f2)singleFplot(cax,{f1,f2},limits,extraOpts,args) (line 208)
In fplot>vectorizeFplot (line 208)
In fplot (line 166)
In task4plot (line 7)
Index exceeds the number of array elements (1).
Error in sym/double (line 699)
S.digits(max(oldDigits, 16));
Error in sym/unique (line 108)
indA = double(indA);
Error in countvars>symvarMulti (line 11)
vars = reshape(unique([vars{:}]),1,[]);
Error in countvars (line 5)
n = numel(symvarMulti(outer));
Error in fplot>singleFplot (line 236)
nvars = countvars(fn);
Error in
fplot>@(f1,f2)singleFplot(cax,{f1,f2},limits,extraOpts,args)
(line 208)
hObj = cellfun(@(f1,f2)
singleFplot(cax,{f1,f2},limits,extraOpts,args),fn{1},fn{2},'UniformOutput',false);
Error in fplot>vectorizeFplot (line 208)
hObj = cellfun(@(f1,f2)
singleFplot(cax,{f1,f2},limits,extraOpts,args),fn{1},fn{2},'UniformOutput',false);
Error in fplot (line 166)
hObj = vectorizeFplot(cax,fn,limits,extraOpts,args);
Error in task4plot (line 7)
fplot(y_rt,x_rt,'r-');
>>
Antworten (1)
Star Strider
am 5 Feb. 2021
Try this:
syms x_rt y_rt
Pp_Pr = 0.3;
alpha = 100;
% x_rt = [0.1;0.01;1];
Eqn = x_rt == y_rt * (1 + Pp_Pr * (1-y_rt) * (alpha - 1)) / (alpha - (alpha - 1) * y_rt)
y_rt = rhs(isolate(Eqn,y_rt)) % Create Function From Right-Hand-Side Of ‘Eqn’
figure
fplot(y_rt,[0.1 1],'r-')
It adds ‘Eqn’ as the expression to be solved, then solves ‘x_rt’ for ‘y_rt’ using the isolate function. The rest is straightforward.
Kategorien
Mehr zu Subplots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!