Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I am trying to compile a code for MATLAB. Actually is in C and there is an implementation in matlab. Thus I am using MinGW64 Compiler (C) compiler in order to compile the files. I am running the compiler script which actually compiles using the cmd all the c files. My problem is with a line with fflush(stdout); When I tried to run that command I am receiving the following message:
Undefined function or variable 'stdout'.
I am trying to figure out why am I receiving that error, and what is about.
The code is the following:
disp('Compiling for Matlab...');
gcc = 'mex';
cd mex;
% =============
% Learning code
disp('Learning:');
files = {'qp_one_sparse.cc', 'score.cc', 'lincomb.cc'};
matlabflags = '-O -largeArrayDims';
for n = 1:length(files)
cmd = [gcc ' ' matlabflags ' ' files{n}];
disp([' ' cmd]);
fflush(stdout);
eval(cmd);
end
I got issues with fflush(stdout); line
fflush(stdout) is valid in Octave but not MATLAB.
If you need to flush the output, you can drawnow to achieve the same effect in MATLAB.
drawnow('update')
The update parameter ensures that only non-graphical queues are flushed.
In newer versions of MATLAB, the following is preferred but either should work.
drawnow('limitrate')
That being said, I'm not sure that you even need it for the code that you've posted.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 days ago.
This post was edited and submitted for review 5 days ago.
Improve this question
Basically I want a key able to be pressed during the entirety of the while True loop. I have tried sys, etc, termios, keyboard and tty with they're respective pip command in terminal on my Raspberry Pi and still no luck any help would be much appreciated. the IDE used is the Thonny IDE with python3.7 running
In short I would like to have a key press available 24/7 In a while loop on a Raspberry Pi python 3.7 Thonny IDE and get the Traceback of
termios.error: (25, 'Inappropriate ioctl for device')
this is where i want to add it but my lab says otherwise
while True:
draw.rectangle((0,0,width,height), outline=0, fill=0)
myfile = open("TempSetm.txt",'r')
for line in myfile:
tempm = line
myfile.close()
sleep(3)
#buncha stuff that the prints stuff out to oled display
code used to get issue was this one
import tty, sys, termios
filedescriptors = termios.tcgetattr(sys.stdin)
tty.setcbreak(sys.stdin)
x = 0
while 1:
x=sys.stdin.read(1)[0]
print("You pressed", x)
if x == "r":
print("If condition is met")
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, filedescriptors)
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I am trying to debug a Perl Script, which uses the Text Balance extract bracketed function on some text that is enclosed in curly braces.
Unfortunately, the function returns nothing, not in the extracted or the remainder and there is error.
Is there a way where I can find out there reason for its failure? Is it possible for it to throw an exception saying for example, not able to extract because of the data structure. At the moment without knowing why, I can't really solve the problem.
See the Diagnostics section of the doc.
In addition, on failure in any context, the $# variable is set. Accessing $#->{error} returns one of the error diagnostics listed below. Accessing $#->{pos} returns the offset into the original string at which the error was detected (although not necessarily where it occurred!) Printing $# directly produces the error message, with the offset appended. On success, the $# variable is guaranteed to be undef.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I have a problem to cd into my usb drive (F:) using PowerShell and I can't use variables becouse I am starting PowerShell with Start-Process. I tried using
cd (Get-Volume -FileSystemLabel NameOfUsb).DriveLetter:
and it almost works but "F" has a space after it and ":" is in new line so it spits out error.
Is there any way to do it? It don't have to be using that method
You really should include the full Start-Process line you are trying to run. However, this should do what you want.
cd "$((Get-Volume -FileSystemLabel NameOfUsb).DriveLetter):\"
I'm extremely new to both working on Linux and Fortran, so apologies if this is a basic question.
I am trying to firstly use fwrite to save a 60x150 array that I've produced in MATLAB as a binary file, which I am then attempting to load and read in Fortran as a 60x150 array again.
In Matlab, I have used the following code to save the array. In this case the name of the array in the workspace is VP, and I'm saving it to a file also called 'VP':
>> fileID = fopen('VP','w');
>> fwrite(fileID,VP,'real*8');
>> fclose(fileID)
Next, I am copying the file over from Windows to a linux ssh server (I'm not sure if this is relevant, but thought it's worth including anything that might help).
Now, in my Fortran code, I've got:
REAL(KIND=kind(1.0D0)), DIMENSION(60,150) :: VP
...
open(unit, file="LOCATION/VP", access = "stream", form = "unformatted", iostat = stat)
if(stat /= 0) labort("Failed to open input file")
print *, wl
DO inx2=1,60
DO inx=1,150
print *,inx
READ(unit,*) VP(inx2,inx)
ENDDO
ENDDO
print *,VP(1:10,1)
Now, when I compile this there are no errors. However, when I run it, it gets to exactly the first "READ(unit,*) VP(inx2,inx)" before failing (you can tell from the print just before it).
I get the error:
forrtl: severe (257): formatted I/O to unit open for unformatted transfers, unit 111, file LOCATION/VP
Obviously I would like my actual result to be the function running and ending up with the same values in the array.
Now I've seen the question before, specifically for this error message, but that was answered by including access="stream" which I have already. Basically I am not sure at what point I am getting something wrong in this process, any help would be appreciated.
Note some things I have tried is changing the precision in fwrite, and swapping the inx2 and inx values around (but it fails on the first one so I don't believe that's the error).
Again this might be just a fundamental issue with my understanding of Fortran because I've been thrown in the deep end a bit with a project I'm working on (most of the code I'm running was produced by someone else, I'm just trying to edit a small part of it).
Edit:
Okay, thank you so much francescalus! He found the solution was to edit the line to READ(unit) VP(inx2,inx) in order to get it to run. However, the values I get by running the next line of code:
print *,VP(1:10,1)
Only the first value matches the first value in my original matlab array. Displaying VP(1:5,1:5) of the matlab array there aren't any other matching values. I might be able to figure this out on my own but as I'm already here I might as well ask as I haven't fully completed the original question (although got over a big hurdle!).
Edit 2:
Okay the next bit I've managed to figure out for myself. If anyone is searching though it was simply a case of swapping the DO loops. ie
DO inx=1,150
DO inx2=1,60
print *,inx
READ(unit,*) VP(inx2,inx)
ENDDO
ENDDO
Thanks for the help.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I am trying to run this code, but have reached a dead end due to my inexperience.
http://dde.binghamton.edu/download/camera_fingerprint/
The code is trying to call the Cpp fucntion mdwt in MATLAB, and that gives error. I changed the function call in MATLAB to coder.ceval but that gives the error "Too many output arguments." I would be grateful to anyone who would point out what I am doing wrong in implementing this code. Thanks in advance!
These files are source code for mex functions, which can be compiled using the mex command. The compile.m from the zip file contains the necessary commands to compile the mex files.