Octave: invalid use of script in index expression

I want to use simple code ( plot.m) in Octave to build a drawing. My code is as follows:

printf('Plotting Data...\n');
x = -10:0.1:10;
plot(x, sin(x));

But I get an error message:

error: incorrect use of script ex1 / plot.m in an index expression error: called from the graph in row 3 of column 1

Could you tell me how to solve it? Thank!

+4
source share
2 answers

I have the same problem to solve it

  • changed script name
  • removed previous scripts (which have the old name and contain the same scripts)
  • write an octave, enter the file name "without m" (write "file" instead of "file.m")

here is my script and called it "xx.m"

syms x;
f = x^3 - 6*x^2 + 11*x - 6; 
ezplot(f)
xlabel("x") 
ylabel("y") 
title ("name")
grid on

xx run xx, .

-, " script"

  • script . , my script "ezplot.m" "ezplot (f)", . , , script
  • m , script , . , script.
+3

: script.


somefunction(), Octave somefunction.m . 1 , somefunction . , ( - ).

plot(). script plot.m. Octave plot.m ... script! , plot.m script, . (, x sin(x) ), " script ".

, , , plot.m.


1 , somefunction. , .

+4

Source: https://habr.com/ru/post/1664240/


All Articles