As the title says, I have looked over my code and I don't see a reason that my script is not printing out the images. In particular, I have solution code that does print out the images and I don't see any differences in the code so I'm at a bit of a loss. The code does throw errors at unfinished lines, however there should still be printed images in the first few sections, the errors shouldn't interfere with that so I still don't know why they don't print out. My code is as follows:
EDIT: Some of my classmates have the same error, I suspect it might be a path issue but I'm not sure how to address that.
EDIT2: I've reformatted the post to be clearer, sorry for including extraneous parts of this code. The document is a .mlx file, hence where there is code and text interspersed. The code did not run when I used the "Run section" button, however if I copied and pasted the coded into the Command Window it would run without issue.
P = phantom('Modified Shepp-Logan',300);
figure
imshow(P);
imwrite(P, 'raw1.tif');
This section of the code seems to be working as expected when I tested it on MATLAB R2019b.
P = phantom('Modified Shepp-Logan',300);
figure
imshow(P);
imwrite(P, 'raw1.tif');
As an aside, all files will be saved to the current working directory unless otherwise specified.
Steps Taken:
To Run Script
Home Tab → New Script → Paste Script → Editor Tab → Run
and Give Script Save Name
To Easily Open Exported/Saved File:
Current Folder Side Panel → Right Click On File → Open Outside MATLAB
Results
Extension: Other Cool Tricks (to avoid running unfinished lines)
Using %% can be used to separate the script into sections. Each section can be run using the Run Section Button in the EDITOR tab or can be run using the command:
Windows: Ctrl + r
MacOS: ⌘ + r
Section 1 Code
%%
Section 2 Code
%%
Section 3 Code
Using MATLAB version: R2019b
Related
I just installed Win 10 1809 on my Dell PC, and it seems to run okay. But the first thing I did was start up VS Code. I wanted to run yarn start for my React project, but I had to type it way down in the terminal window, while the prompt was at the top. It worked though.
And when I open any project file, there seems to be approximately 100 blank lines appended at the end of each. But the line numbers don't go down that far and the cursor stops at the last line number. But the scroll bar acts as if those blank lines are there.
So I'm guessing the same number of blank lines are being added to the terminal too. But in the terminal window, the cursor is positioned at the bottom of the scrollable window.
What's going on? Is there a fix?
EDITED:
I see that I can scroll the file's window up until the cursor and last line is at the top, but no further, regardless of the window size. Maybe this has always be the case, and I never noticed. But now because of my terminal problem, I am suspicious of everything and checking for any abnormalities. So I don't think that extra blank lines are being added to my files. Sorry for the mistake.
But the terminal problem persists. The screen clip below shows the terminal display after I enter "yarn start". The typed input shows up way down from the initial prompt, and the blank area is a long string of "0D0A" characters. Sometimes I can click on "kill Terminal" and then start a new one and the new one works correctly. But not always.
Still trying to figure this out.
Can you share snapshots for your problems?
This is some hint for your problem
In VS Code, type
Linux / Windows: Ctrl + Shift + P
MacOS: Cmd + Shift + P
Type Settings to go Settings
At settings, search end of file, at here you can configure something for your problem with auto append blank lines each file
I hope it will help you :)
Your Terminal Problem is described as Bug in VS Code Issues.
As of July 2019 the intergration is pending due to stability problems.
https://github.com/Microsoft/vscode/issues/57803
Addendum (August 2019):
The Problem seams to be fixed with VS Code 1.37.1 and Windows 10 Patchlevel 1903
Did you try uninstalling and reinstalling?
Going back to your questions.
What's going on? No idea.
Fix. Use this extension https://marketplace.visualstudio.com/items?itemName=rintoj.blank-line-organizer
or
Open Visual Studio project and collapse all the folder and make it handy.
Now press “ Control + Shift + H “ key combination and you can see the Popup which shows Find and Replace options.
In the Find place input “^&\n” combination and select Use Regular Expression checkbox without fail as this input will mainly work with the regular expressions only.
In the replace field leave it empty so nothing will be replaced rather remove the empty blank lines.
In the input Find field we have give ^ for Start of the line and $ for end of line and \n which is for new line break.
source for second solution: http://www.f5debug.net/post/2015/01/03/How-to-remove-Blank-lines-between-codes-in-Visual-Studio-Code-editor.aspx
The extension will be useful overall especially when working in a team project where a lot of people might be leaving too many empty lines. Good luck
I am not sure if this is a reasonable expectation or whether there are other IDEs that have this feature, but when I am writing code in the RStudio editor, once I have written a sufficient amount of code, I am basically always editing at the bottom of the screen:
Is there a way to move the code to the middle of the screen without having to type "Enter" a bunch of times (trailing newlines are code too :-))?
You can keep scrolling by clicking an option in the settings:
Tools -> Global Options -> Code -> Display -> Allow scroll past end of document
This only affects scripts, and not the console.
So, uh.. you got some more of that fake internet points?
Since few days (since the last version of xcode?), I noticed that the syntax color takes sometimes a while to appear and sometimes doesn't even appear, then I need to "reload" the file by clicking on another file and going back to the current one.
I tried to solve it by deleting the derived data but it didn't solve my problem. It is quite annoying as it seems I cannot click on a method (and go to its definition) if the syntax color is not ready.
Any idea?
So briefly, my problem was about some lines of code that had a hard time to compile and was taking the whole compilation process ages. It was linked to my problem probably because Xcode quickly compiles the file you're working on before enabling any inner link/color for the code.
So if your compilation takes a while here is how you can quickly find out what's the problem (if it is related to some of your lines of code)
So I found some help on some website to find out what it was but I can't give you the links as I don't remember them. So here is how I proceed.
First when you compile, go on the Report Navigator on your left and select the Build being built. Then in your main tab, try to look for the file that takes a while to compile (it is the one that should stay with the arrow longer than the other ones). Once you found it, select the line of the file and on the very right side, there is a button that will expand a tab showing the command to compile your file with Terminal.
Copy the part starting with /Applications/Xcode.app/Contents/Developer/Toolchains to the end (name_of_your_file.o) and paste it in the Terminal.
If you execute it, it should take more than just 3-4 seconds.
Then when you execute it, you have to press Ctrl(^) + \, you will send a quit signal and it will cause the process to terminate and dump core, showing you the line and the code it was compiling so most probably the part that was taking a long time.
In my case, one of the problematic lines was
maximumValue = CGFloat(abs(high + (15/100) * (high - low)))
I replace it by
let maximumValue = abs(high + (15/100) * (high - low))
maximumValue = CGFloat(maximumValue)
and it solved my problem. Why this piece of code was causing problem is another question...
I found that is also was a line that seemed too complex to process. I found that if I typed "let bob = UII" at the very top of the class, the syntax highlight worked fast, whereas at the bottom of the file, it was crazy slow. The simplest way I found was to simply try the "let bob = UII" at half way, and then basically halve and halve again. My problem turned out to be calculating a variable with multiple calculation and additions. Broke it up over 4 lines and everything is fine again.
This is my first time on this amazing forum. I am also very new to vba (3 weeks).
I have 2 macros: CallerMac, WorkerMac. These are in separate modules within the "Modules" node of my VBAProject.
In its code, CallerMac imports a .bas file (which has the WorkerMac code) and executes it through a " Application.Run"
When the user is handed this code, they will run "CallerMac" (whose code wont change much) while the code imports the "WorkerMac" (likely to change often)
How can I, for debugging purposes, "F8"/Step into the copied code (WorkerMac) during execution?
Please let me know how I can rephrase my question if it doesn't say much to you or if I should have searched for it differently (I did a lot of searching before posting this code)
Many thanks.
You can place a breakpoint at the beginning of "WorkerMac" as you step through "CallerMac", and then use F8 to continue running "WorkerMac" in step mode.
You can add breakpoints by right clicking on a line that is an executable statement and going to Toggle->Breakpoint, or by clicking on the bar on the left next to the code. It should show a red circle in the bar and highlight the line in red.
How does one setup and start using vim in the terminal on OS X?
I want to start writing my C code using vim in the terminal rather than a separate text editor. How does one get started on this?
The basics like: opening, creating, saving files via terminal using vim and writing code using vim. Also, does one compile directly using vim in the terminal?
Get started quickly
You simply type vim into the terminal to open it and start a new file.
You can pass a filename as an option and it will open that file, e.g. vim main.c. You can open multiple files by passing multiple file arguments.
Vim has different modes, unlike most editors you have probably used. You begin in NORMAL mode, which is where you will spend most of your time once you become familiar with vim.
To return to NORMAL mode after changing to a different mode, press Esc. It's a good idea to map your Caps Lock key to Esc, as it's closer and nobody really uses the Caps Lock key.
The first mode to try is INSERT mode, which is entered with a for append after cursor, or i for insert before cursor.
To enter VISUAL mode, where you can select text, use v. There are many other variants of this mode, which you will discover as you learn more about vim.
To save your file, ensure you're in NORMAL mode and then enter the command :w. When you press :, you will see your command appear in the bottom status bar. To save and exit, use :x. To quit without saving, use :q. If you had made a change you wanted to discard, use :q!.
Configure vim to your liking
You can edit your ~/.vimrc file to configure vim to your liking. It's best to look at a few first (here's mine) and then decide which options suits your style.
This is how mine looks:
To get the file explorer on the left, use NERDTree. For the status bar, use vim-airline. Finally, the color scheme is solarized.
Further learning
You can use man vim for some help inside the terminal. Alternatively, run vimtutor which is a good hands-on starting point.
It's a good idea to print out a Vim Cheatsheet and keep it in front of you while you're learning vim.
Run vim from the terminal. For the basics, you're advised to run the command vimtutor.
# On your terminal command line:
$ vim
If you have a specific file to edit, pass it as an argument.
$ vim yourfile.cpp
Likewise, launch the tutorial
$ vimtutor
You can definetely build your code from Vim, that's what the :make command does.
However, you need to go through the basics first : type vimtutor in your terminal and follow the instructions to the end.
After you have completed it a few times, open an existing (non-important) text file and try out all the things you learned from vimtutor: entering/leaving insert mode, undoing changes, quitting/saving, yanking/putting, moving and so on.
For a while you won't be productive at all with Vim and will probably be tempted to go back to your previous IDE/editor. Do that, but keep up with Vim a little bit every day. You'll probably be stopped by very weird and unexpected things but it will happen less and less.
In a few months you'll find yourself hitting o, v and i all the time in every textfield everywhere.
Have fun!
if you want to open all your .cpp files with one command, and have the window split in as many tiles as opened files, you can use:
vim -o $(find name ".cpp")
if you want to include a template in the place you are, you can use:
:r ~/myHeaderTemplate
will import the file "myHeaderTemplate in the place the cursor was before starting the command.
you can conversely select visually some code and save it to a file
select visually,
add w ~/myPartialfile.txt
when you select visualy, after type ":" in order to enter a command, you'll see "'<,'>" appear after the ":"
'<,'>w ~/myfile $
^ if you add "~/myfile" to the command, the selected part of the file will be saved to myfile.
if you're editing a file an want to copy it :
:saveas newFileWithNewName
If you want to learn by reading yourself:
Open MacOS terminal app.
Write this and press enter -> vimtutor
For quit write this and click -> :q