[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #55134] fplot failing on non-vectorized functi
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #55134] fplot failing on non-vectorized function |
Date: |
Thu, 29 Nov 2018 16:35:47 -0500 (EST) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063 |
Update of bug #55134 (project octave):
Status: None => Need Info
_______________________________________________________
Follow-up Comment #1:
I'm very surprised that Matlab handles this, but I suppose they must have
written a lot of input validation.
The trouble is not that your original function is not-vectorized, but that the
subfunctions aren't.
The line
fplot(@findX1, [0 12]);
tries to plot the function findX1
function [x1] = findX1(K)
% FINDX1 Finds the first element of the vector x for a given K
% Inputs
% K - a constant
% Outputs
% x1 - the first element of x
x = findXall(K);
x1 = x(1);
end
, but this function depends on findXall
function [x] = findXall(K)
% FINDXALL Finds the vector x for a given K
% Inputs
% K - a constant
% Outputs
% x - a vector
A = [5-K -2 4;
-5 4+K 3;
5 2 1+K];
b = [10; 4; -1];
x = A\b;
end
You can see that the construction of the matrix A is going to fail if K is not
a scalar constant or a row vector. Can you modify testfplot.m so that you
take the transpose of K in the construction of A and then re-run it under
Matlab?
Here is the new function I would like tested.
function [x] = findXall(K)
% FINDXALL Finds the vector x for a given K
% Inputs
% K - a constant
% Outputs
% x - a vector
A = [5-K' -2 4;
-5 4+K' 3;
5 2 1+K'];
b = [10; 4; -1];
x = A\b;
end
I made that change and have uploaded the file as new_tst_fplot.m. With this
change, Octave runs fine. I'm attaching the plot which you can also verify
looks more or less like the one from Matlab.
(file #45555, file #45556)
_______________________________________________________
Additional Item Attachment:
File name: fplot.png Size:17 KB
File name: new_tst_fplot.m Size:0 KB
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?55134>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/